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

ItemContainerGenerator: new return type of IContainerGenerator

3 Answers 102 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 05 Nov 2012, 10:25 AM

Hi

In Q3 2012 the return type of RadGridView ItemContainerGenerator is IContainerGenerator.
Before, the return type was GridViewItemContainerGenerator.
Why has it changed? And how could I now register the StatusChanged Event?

And what is about the Property Status in the Class GridViewItemContainerGenerator? (the Property is removed in Q3 2012)

Thank you, kind regards
Bruno

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 05 Nov 2012, 11:28 AM
Hi,

With Q3 we introduced a brand-new virtualization mechanism with a completely new item container generator. This is described in the release notes. In grouped scenarios the new virtualization strategy yields scrolling performance tens of times better than the "old" virtualization. This new mode can be enabled by setting RadGridView.GroupRenderMode to Flat.

For compatibility reasons we have kept the old virtualization strategy as well (GroupRenderMode=Nested) whic is the default setting. We had to create a public interface for the two different item container generators called IContainerGenerator. It does not have a StatusChanged event since the new generator does not support such a notion.

In case you are using the "old" virtualization mode, which is the default setting, you can safely cast RadGridView.ItemContainerGenerator to GridViewItemContainerGenerator (the old generator) and use its properties and events, in this case the StatusChanged event.

But we do not recommend using the StatusChanged event, since this is not advertised anywhere in our documentation and we might remove it for a future version.

We are very intereseted in what scenarios did you listen for the StatusChanged event? What was the purpose of attaching to this event? What did you do in the event handler? Maybe there is a more proper way to achieve your goal. Can you please elaborate?

Best Regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Bruno
Top achievements
Rank 1
answered on 05 Nov 2012, 02:00 PM
Hi

Thank you for your reply.
We have following scenario:
A TreeView and a GridView. The GridView has a GridViewColumn with a CellTemplate of TextBox.
If I add a new Entry to the TreeView (this new Entry will also be directly selected), this new Entry will also added to the GridView.
In the SelectionChanged Event of the TreeView I would like to select the focus on the suitable Record (TextBox) on the GridView.
For these Scenario, we had registred the ItemContainerGenerator.StatusChanged Event (in the TreeView SelectionChanged Event) on the GridView. If the Status were 'ContainersGenerated', we have access to the TextBox of the Selected GridView Item(GridView.ItemContainerGenerator.ContainerFromItem(GridView.SelectedItem)).
If we could not prompt of the GridViewItemContainerGenerator Status, the ContainerFromItem Method returns NULL.

Kind Regards
Bruno

0
Rossen Hristov
Telerik team
answered on 05 Nov 2012, 03:39 PM
Hello,

I see now.

So you have two options.

1. You can safely cast RadGridView.ItemContainerGenerator to GridViewItemContainerGenerator and work just like you did before.

2. A more correct approach: You can try subscribing to the RowLoaded event of RadGridView. It will be fired for each row that is realized when there is virtualization. The event arguments will give you the row that has just been realized, i.e. e.Row. You can get the data item displayed in this row by reading e.Row.Item.

So in the event handler of RowLoaded you can check whether e.Row.Item == grid.SelectedItem and in case it is true you can do your thing there.

Also, if you are trying to get a row for an item in other places, RadGridView has a public method called GetRowForItem which we recommend using. This is our public facade and we will not change it even though we might change the implementation that is beneath it.

In short, working directly with the item container generator is not a very good idea, since we might obsolete it in the future. Your best option would be to use the public methods and events of RadGridView.

I hope this helps.

All the best,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Bruno
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Bruno
Top achievements
Rank 1
Share this question
or