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
Hello Shaolin,
There is no way to force InitializeRowsCollection to fire manually. If you describe what you want to accomplish by firing InitializeRowsCollection again, I can look into a strategy to accomplish this instead of InitializeRowsCollection.
Please let me know if I can further assist you.
Hi John,
Thanks for your response!
As I stated in my original question, the data in my own data source constantly change, including child record collections. The data in my own data source are added, updated and removed by work threads. The number of rows in any child row collection is changed all the time, so event InitializeRowsCollection has to be fired. When there is any data change in my data source, I will call:
ultraDataSource.Rows.SetCount(newCount);ultraGrid.Rows.Refresh(RefreshRow.FireInitializeRow);
The InitializeRow event is forced to fire this way. I do not see event InitializeRowsCollection is fired.
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.
Please let me know if I can be of further assistance.
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.
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.
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?
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 Mike,
Okay, it was my mistake that I thought GetChildRows would return all child rows for the specified child band.
Thanks so much,Shaolin
Hi,
You answered your own question. You use the GetChildRows method. This returns you the child rows collection of that row. Then you call SetCount on it.
I need the child row collection. Let's assume we have two bands. I have a row, called Row1, in the root band that have initially have five children, so there are five child rows under Row1. A few seconds later, two more children needs to add to this parent row Row1. I can get this Row1 from my UltraDataSource. Now I need to get the child row collection of Row1. I know Row1's child row collection have five items and I need to set its Count to 7.
Shaolin said:It seems I cannot find a method to get child UltraDataRow collection for a parent UltraDataRow object from UltraDataSource. UltraDataRow has a couple of GetChildRows methods and they return all child rows in a child band.
I'm not sure what you are asking. You seem to have answered your own question.
Shaolin said:How can I get the associated rows collection in the UltraDataSource, by going through all child data rows in the child band?
UltraDataRow has both a Parent and a ParentCollection property. Is that what you are looking for?
Thanks so much for your response!
It seems I cannot find a method to get child UltraDataRow collection for a parent UltraDataRow object from UltraDataSource. UltraDataRow has a couple of GetChildRows methods and they return all child rows in a child band.
Mike Saltzman said:All you need to do is get the associated rows collection in the UltraDataSource and call SetCount on that collection.
How can I get the associated rows collection in the UltraDataSource, by going through all child data rows in the child band?
My own data source only holds a list of top level records and each record contains a child collection. Of course, a child record can have its own children. I only know the number of records in the top level.
Your help is greatly appreciated!
Thanks again,Shaolin