View previous topic :: View next topic |
Author |
Message |
xsv
Joined: 28 Feb 2007 Posts: 5
|
Posted: Wed Feb 28, 2007 10:44 am Post subject: Refresh problems in VT3.3.0 |
|
|
Hi!
I just upgraded from 3.1.2 to 3.3.0 and I run into some refresh problems in Virtual Tree.
Looking into the problem I think found the cause of my problem.
It looks like there is some new functionally between 3.1.2 to 3.3.0 in VirtualTree.GetBindingForRow.
There seems to be some new cache functionality that prevents my event handler from getting called.
Some background info:
My event handler for “GetBinding” looks like this:
private void vt_GetBinding(object sender, GetBindingEventArgs e)
{
RowBinding bind = vt.GetRowBinding(e.Row);
if (bind == rowBindingUnit)
{
if (((DataRow)e.Item).RowState == DataRowState.Modified)
{
bind = rowBindingUnitUpdate;
}
else if (((DataRow)e.Item).RowState == DataRowState.Added)
{
bind = rowBindingUnitInsert;
}
}
e.RowBinding = bind;
}
rowBindingUnitUpdate and rowBindingUnitInsert are created exactly like rowBindinfUnit exept for the background color.
As a result of this I get different background color depending on RowState of the DataRow.
My problem:
In the example below the “vt_row” is an Infralution.Controls.VirtualTree.Row
and vt_row.Item points to a DataRow(dr)
dr["Status"] = Status.None; // binds to rowBindingUnitUpdate
dr.AcceptChanges(); // no “change”-events are fired here
vt.UpdateRowData(vt_row); // try to update row...
In 3.3.0 my event handler vt_GetBinding no longer get called
and as a result I get the wrong background color.
Would it be possible to dissable row-binding-caching??
Best Regards
/Stefan Vestin |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Feb 28, 2007 9:33 pm Post subject: |
|
|
You are correct - we introduced caching of RowBindings to improve performance when using ObjectBinding/DataSetBinding. This does mean that your GetBinding event will only get called once per row. We can look at providing some control over this.
You can however still implement your required functionality with the caching mechanism. Instead of handling the GetBinding event, handle the GetCellData and GetRowData events and use similar logic to select the binding to use to fill the cell/row data eg
Code: | private void _virtualTree_GetCellData(object sender, Infralution.Controls.VirtualTree.GetCellDataEventArgs e)
{
RowBinding bind = _virtualTree.GetRowBinding(e.Row);
if (bind == rowBindingUnit)
{
if (((DataRow)e.Item).RowState == DataRowState.Modified)
{
bind = rowBindingUnitUpdate;
}
else if (((DataRow)e.Item).RowState == DataRowState.Added)
{
bind = rowBindingUnitInsert;
}
}
bind.GetCellData(e.Row, e.Column, e.CellData);
} |
_________________ Infralution Support |
|
Back to top |
|
|
xsv
Joined: 28 Feb 2007 Posts: 5
|
Posted: Thu Mar 01, 2007 10:07 am Post subject: |
|
|
Tanks for the quick reply!
Caching the binding sound like a really good idea, but wouldn’t it better if this caching functionality only occurs when using the “default”-binding and not when the GetBinding-event is used.
In this case it would be up to the implementer of the GetBinding event handler to cache bindings if necessary.
I did some digging in another part of my code where version 3.3.0 caused some refreshing problems. In this case Object binding is used and I have an event handler for the GetBinding event.
myObjInstance.Property1=”some new value”;
causes a PropertyChanged event and eventually a call to GetBinding event handler.
Later on in the code:
myObjInstance.Property2=”some new value for Prop2”;
If the GetBinding event handler uses data from Property2 there is a problem since the GetBinding event handler is not called.
Switching the order of the assignments would then make a difference
myObjInstance.Property2=”some new value for Prop2”;
myObjInstance.Property1=”some new value”;
would give the correct behaviour but
myObjInstance.Property1=”some new value”;
myObjInstance.Property2=”some new value for Prop2”;
would result in refreshing problems.
Possibly I have missed some important information but using the GetBinding event could really give you some unforeseen behaviour as the assignment order now would make a difference.
So would it be possible to make a wish for something like
Code: |
public RowBinding GetBindingForRow(Row row)
{
RowBinding ret;
if (row == null) return null;
if (GetBinding == null)
{
if (row == _cachedBindingRow) return _cachedBinding;
_cachedBinding = GetRowBinding(row.Item, row);
_cachedBindingRow = row;
ret = _cachedBinding;
}
else
{
GetBindingEventArgs e = new GetBindingEventArgs(row);
GetBinding(this, e);
ret = e.RowBinding;
}
return ret;
}
|
Tanks for a really nice component!
Best Regards
/Stefan Vestin |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Mar 01, 2007 9:06 pm Post subject: |
|
|
I have had a look at the problem and I think a better solution would be to simply to clear the cached binding when UpdateRowData (or UpdateRows) is called. That way you get the performance benefit of cached bindings (which is substantial when you have a number of columns) but if your underlying data changes the cache is not used. _________________ Infralution Support |
|
Back to top |
|
|
xsv
Joined: 28 Feb 2007 Posts: 5
|
Posted: Mon Mar 05, 2007 9:23 am Post subject: |
|
|
Yes! That sounds like a better solution!
Both solving my problems and keeping the performance
Any idea when a change like this could be implemented and released?
Best Regards
/Stefan Vestin |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Mar 05, 2007 11:07 am Post subject: |
|
|
We can probably have something released by the end of this week. _________________ Infralution Support |
|
Back to top |
|
|
xsv
Joined: 28 Feb 2007 Posts: 5
|
Posted: Mon Mar 05, 2007 12:35 pm Post subject: |
|
|
That would be very much appreciated!
MANY THANKS!
Best Regards
/Stefan Vestin |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Mar 06, 2007 11:23 pm Post subject: |
|
|
We've now released Version 3.3.1 that should resolve this for you. _________________ Infralution Support |
|
Back to top |
|
|
xsv
Joined: 28 Feb 2007 Posts: 5
|
Posted: Wed Mar 07, 2007 2:29 pm Post subject: |
|
|
Hi again!
I just installed 3.3.1 and my problems still exists.
I was unable to download the source for 3.3.1 (it was still 3.3.0 in VirtualTree3.zip) but looking at the de-compiled code using Reflector, it looks like UpdateRowData() clears the binding cache,
but UpdateRowData(row) does NOT clear the cache.
So my initial problem still exists.
A call to UpdateRowData(row) doesn’t always result in a call to my GetBinding event handler.
Also notice that my other problem also still exists.
That is, the assignment order of data makes a difference (only the first assignment results in a call to the GetBinding event handler)
Would it be possible to have the overloaded method
UpdateRowData(row) to also clear the binding cache?
Best Regards
/Stefan Vestin |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Mar 07, 2007 9:51 pm Post subject: |
|
|
You are right we overlooked the overloaded UpdateRowData(row) method. I think adding the ClearBindingCache call to this method will also fix your other issue. You could verify this by overriding the UpdateRowData(row) method as follows:
Code: | public override void UpdateRowData(Row row)
{
ClearCachedRowBindings();
base.UpdateRowData(row);
} |
We will fix this ASAP. _________________ Infralution Support |
|
Back to top |
|
|
StrifeSD
Joined: 30 Nov 2006 Posts: 24
|
Posted: Thu Mar 08, 2007 4:26 am Post subject: |
|
|
I'm seeing the same problem. When will this be fixed? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Mar 09, 2007 12:19 am Post subject: |
|
|
OK we've now released Version 3.3.2 which adds the ClearBindingsCache call to UpdateRowData(row). Hopefully this will resolve your issues. _________________ Infralution Support |
|
Back to top |
|
|
|