Hello,
I have a two band UltraGrid in virtual mode. The data in my data source constantly change, including child record collections. It seems that the InitializeRowsCollection is only fired once for each parent row. Is there a way to force InitializeRowsCollection to fire again?
Thanks,Shaolin
Hi Shaolin,
I understand exactly what you are trying to do. The number of rows in the child collection of your data has changed, so you need to tell the associated child rows collection in the UltraDataSource that the count has changed.
But there is no reason why you would need an event for this. Events fire to tell you, the developer, that something happened. But in this case, you already know that it happened. You don't need to artificially trigger another event to respond to something you already know happened.
All you need to do is get the associated rows collection in the UltraDataSource and call SetCount on that collection. You can simply do that directly, there's no reason to fire an event to do it in a roundabout, indirect way.
The InitializeRowsCollection event only fires when the collection is initially created. So one thing you might want to do is create some kind of dictionary or mapping inside that event so that you can easily map the collections in your underlying data to the corresponding rows collection in the UltraDataSource, so that it's easier to find when the row count changes. Or, you could find some other way to locate and access the rows collection. How you do that depends on your data structure and what you know about the data.
Hi John,
You still haven't got what I asked for. I am talking about change to a child row collection in a child band. Let's assume I have a record that has five children, so the corresponding parent row in the grid have five child rows. Five seconds later, two new children are added to this collection and now this parent row in the grid should have SEVEN child rows instead of five. I have to let grid know this parent row has seven children now. I cannot tell my UltraDataSource about changes to the child row collections directly. It seems to me that InitializeRowsCollection is only way to do so.
Could you please talk to your manager or another developer please?
Hello Shaolin,
No event is necessary in order to make these changes to your UltraDataSource. Whatever event is occurring on your side to announce a change in the underlying data source, at that same occurrence the new number of rows in the UltraDataSource can be set.
Please let me know if I can be of further assistance.
Thanks for your response!
I have a grid in virtual mode. Your answer does not make any sense to my question. I can manage to get InitializeRow to be fired for all visible rows, including child rows. But I need a to tell grid a child row collection is changed, so the grid can display right number of child rows for a parent row.
Shaolin,
The InitializeRowsCollection is only fired when the band is first created. As long as that band continues to exist, all modifications can be made to that same collection. When those modifications are submitted to the RowsCollection, InitializeRow is fired. It may be more appropriate to apply the logic you want to the InitializeRow event instead.