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?
The InitializeRow event is intended to allow you to things like color a row or cell based on it's Value. So it is, indeed, supposed to fire every time a value in the row changes.
If you are looping through every row in the grid and changing a value, then it seems likely that there is going to be a performance hit there unrelated to the firing of an event. I doubt that simply firing the event and checking e.ReInitialize is causing any significant performance hit.
But on the other hand, I could be wrong. So you can turn off the event using the grid.EventManager.SetEnabled method. :)
If you are concerned about performance in the grid, you might also want to take a look at this thread: WinGrid Performance Guide
I tried disabling the event but it did not help improve the performance. I have tried everything you have mentioned in the WinGrid Performance Guide. The only thing that is different is that i have an unbound check box column when it works but when i use a bound check box column it takes ages. The trouble is if i add an unbound column and then set the source of grid then in initializerow event i do not get this column in e.Row so i can not set its value. Any pointers on how to do this?
ugrid.EventManager.SetEnabled(GridEventIds.InitializeRow, false);
the event still fires when i set
ultragridrow.Expanded = true;
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 :-(
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.