Hi,
I have an UltraGrid bound to a DataSet. There is an InitializeRow event which initializes the grid rows with some check boxes. Now when i change the value of a cell in code then the event gets fired again. This is odd as the event is supposed to fire when data is bound. This is causing big performance issues as i loop and change value of some cells in all rows in the grid (some 3000 rows). Is there a way to ensure this event fires only when the grid's datasource is set and not for every cell data change in code?
Cheers,
SK
Only do your code if e.reinitialize is false.
Nick
Currently i am doing it like that. But that still does not help performance as the event fires but does nothing. What i wanted to know is, is there any property which is ensure this event fires only when the gird is data bound, otherwise it makes no sense. Why should the event fire when i change data of a cell in my code?
If you have disabled the event and it's still firing for any reason, then that is clearly a bug and you should Submit an incident to Infragistics Developer Support.
The thing is the event fires after i set the row.Expanded = true; so if i disable event before this and enable it after this statment the event fires. Here is my code:
{
ugrid.BeginUpdate();
ugrid.SuspendRowSynchronization();
try
row.Expanded = expcollflag;
crow.Expanded = expcollflag;
}
finally
ugrid.ResumeRowSynchronization();
ugrid.EndUpdate();
ugrid.EventManager.SetEnabled(GridEventIds.InitializeRow, true);
I was able to disbale the event finally by placing a disable statement just after the for loop exits. But it does not solve the performance problem. I have another project in which i do not have this initializerow event and the same code executes in a zap.
What is could be causing this? This is giving me nightmares :-(
Another funny thing is that it runs slowly only for the first time. I.e.Once all rows are expanded subsequent calls to collapse and expand take no time to execute. What is going on here?
Ok i have figured out what the problem is. It is the inability of the Grid (or datasource, read dataset) to load all the child rows when datasource is set. Is there a solution to this problem? I need this functionality to expand / collpse all or selected rows. Do i need to use UltraDatasouce? If yes can i convert a dataset to an Ultradatasource? Where do i start looking for?
contactkalim said:Ok i have figured out what the problem is. It is the inability of the Grid (or datasource, read dataset) to load all the child rows when datasource is set. Is there a solution to this problem? I need this functionality to expand / collpse all or selected rows. Do i need to use UltraDatasouce? If yes can i convert a dataset to an Ultradatasource? Where do i start looking for?
I'm not sure what you mean by this. Loading child rows can be an expensive operation, but that has nothing to do with the grid, it's the data source that determines this. A DataSet, in particular, is pretty inefficient when it retreives child rows. So if expanding rows is slowing down your application, but might want to consider using a more efficient data source. But what you use really depends on the needs of your application, so it's hard to off your any advice on that without knowing a lot more about what you are doing.
It might have saved me some time.
Hm, I guess I must have missed it when you asked how to do that. In any case, there is no automatic conversion, you simply have to loop through the rows and copy the data.
I have used UltraDataSource and converted my Dataset to UltraDataSource. What i really wanted was a sample on how to convert Dataset to UltraDataSource. But i had to do it all myself. This was a bit disappointing after having paid for almost 10 developer licenses for Infragistics.
contactkalim said:What iam doing is that i have a dataset in which i have 2 datatables which have a parent child relationship. This is bound to the UltraGrid. Now I needed a check box and and image column at level 1 rows and disbale level 2 rows. So i was looping through all rows in the Grid to do this. This was making the grid load very slowly. Then i felt may be i should use Initialize row event. That seemed to have fixed the loading problem.
Okay, that makes sense.
contactkalim said:So i thought may be its the problem of the InitializeRow event. But that is not the case as per you and the forum its the datasource which is a Dataset which is slow when fetching child rows. So please suggest me a datasource which serves my purpose otherwise please tell me why should i pay licence fee for this grid. What i wanted to know is how i can use some other datasource in the present condition? I have a Dataset so definetly i should be able to convert this into some other datasource for which the Grid gives me the functionality our users want. Please advice.
Okay. I very much doubt that the InitializeRow event has anything to do with this. As I said, the DataSet tends to be pretty inefficient when you retrieve child rows. This has nothing to do with the grid, and you would experience the same issue with any control that displays hierarchical data.
I don't know of any other data sources that retrieve data from a database, but if you want to use a data source that is more efficient, then you could use the UltraDataSource component. Of course, you would have to load all of the data into this control up front, so that would cause a performance hit. Perhaps there are other, 3rd-party data sources out there that are more efficient than the DataSet.
You might try creating a BindingSource and setting it's datasource to your dataset. Then setting the grid datasource to the bindingsource.
There was a performance problem associated with parent child relationships caused by Microsoft when (VS 2005 came out) I believe.