This is a migrated thread and some comments may be shown as answers.

Row Details Visibility event and Tag

3 Answers 37 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deven
Top achievements
Rank 1
Deven asked on 01 Apr 2011, 03:41 PM

Afternoon,


We have recently upgraded from Silverlight 3 to 4 and found the following behaviour.


On a RadGridView  when a row detail is expanded / collapsed, the RowDetailsVisibilityChanged  event is fired, correctly.  However when the user scrolls down or up the event is fired again and again.


When using Silverlight 3 this behaviour did not happen, i.e. it only fired when the row was expanded or collapsed.


Is there a way to stop this, or should I be subscribing to a different event?



Second question is that we are using the Tag property to allow us to check if we have already retrieved data for the row details that was expanded, e.g.:



if (e.Row.Tag == null)

{

GetDataForRowDetails();
        e.Row.Tag = "notnull";
}
Again after upgrading to Silverlight 4 the tag property looses its value if we scroll away from the row and then bring it back on the view.
Any idea how can we resolve this?


Your help will be much appreciated!

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 04 Apr 2011, 09:11 AM
Hi Deven,

There is not difference between the Row Details implementation across SL3 and SL4. The difference you have described is most probably coming from the fact that the new project has its row virtualization turned on.

When row virtualization is turned on, one and the same physical row (container) is used to host many different data items during its lifetime. When the user scrolls up and down, the physical rows that were used to host a data item which is leaving the view are reused to host the new item coming into the view from the other side. That is the reason for the event firing multiple times. Also, you cannot rely on the Tag since rows will be recycled and reused.

Your only option would be turn row virtualization off. When this is true all of the rows will be realized in the bginning and each physical row will host only one data item during its lifetime. Consequently, the event will be fired only when the user expands or collapses the row details. You will be able to use the Tag as well.

I hope this helps. Let us know if there are problems.

Best wishes,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Deven
Top achievements
Rank 1
answered on 04 Apr 2011, 02:12 PM
Hi Ross,

The EnableRowVirtualization property is set to true in both projects.

Unless I am mistaken the behaviour seems to differ between SL3 and SL4 (Or possilby Telerik versions?)

I didn't really want to turn EnableRowVirtualization off, as I am worried about performance impact.  Any other possible suggestions (Any different events I could map to?)

Thanks again,
Deven.
0
Rossen Hristov
Telerik team
answered on 04 Apr 2011, 02:30 PM
Hi Deven,

Unfortunately, unless virtualization is turned off, the event will fire each time a row is recycled or realized. I am not sure how you were not getting it in SL3, but this does not matter now.

I guess that you are retrieving data by hand in some very complex way when the row details are about to be shown. Otherwise, you would simply use Data Bindings as in all of our examples. 

I have a very simple idea. Create a Dictionary or a HashSet (i.e something to record which data items' row details have been already retrieved) and each time you load the details for a certain data item -- record this data item in this Dictionary. Each time this event is raised you can check whether the data item is in the dictionary and only if it is not you will go and load its row details. In case it is, you will simply return. The data item can be found in e.Row.DataContext in the event handler. In this way you will load the row details for each item only once -- the first time. It is like having a flag set to false initially, then do the job the first time, raise the flag and then don't do the job anymore. 

You can also use the other event called LoadingRowDetails if you decide to. The difference is explained in our online documentation.

I hope this helps.

All the best,

Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Deven
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Deven
Top achievements
Rank 1
Share this question
or