I am handling a fairly complex application where in I am trying to do expand and collapse functionality for rows as well as columns. I have developed the functionality to expand / collapse the columns but I am yet to implement it for rows. The thing is, I have a hierarchical data in a flat 2d array. I do not want to use separate child bands to paint the hierarchy in the Ultra Grid. I just want to show (+/-) bitmaps in the Left most column on the LHS of the cell's TextUIElement. Since the parent child relationship is dynamic, I need a mechanism to include the clickable (+/-) images and different indentation for all the rows, based on the level in the hierarchy. Please let me know how can this be achieved.
Now the data part. I see that there are 2 different sets of events for a row objects for UltraDataSource and UltraGrid objects. For instance, InitializeDataRow and InitializeRow are two such events that deal with the corresponding datasource and grid objects. Similarly, InitializeRowCollection exists. What shall these event handlers implement as per the norms to take the advantage of subscribing to them. In other words, what is the difference between handling these event handlers and just creating a method of our own and calling it to populate the data source. There are another set of events for UltraDataSource viz. CellDataRequested, CellDataUpdating and CellDataUpdated. Do these methods work only in virtual mode when the LoadStyle is set to OnDemand?
I have some doubts as to when to assign the datasource to the grid as depending on when the data binding is done, some of the events may be fired or not. For instance, if UltraDataSource is assigned in the beginning, then along with the events for InitializeDataRow and InitializeDataRowCollection, InitializeRow and InitializeRowCollection may be triggered. But if it is bound early, sometimes unwanted events also get fired. Ofcourse we have the option of adding and removing the handlers. But a better approach is what I seek. I am planning to do the operations on UltraDataSource and UltraGrid separately and then bind them as late as possible.
Typically when shall I apply the styles / appearances, if I am using LoadOnDemand option? The problem is, I am having ValueBasedAppearances sort of situation.
Thank you for posting in our forums!
Based on your description, I believe that such functionality as collapsible rows could be accomplish via using the expanded property of the UltraGrid. For further information, take a look at the following documentation page: http://help.infragistics.com/Doc/WinForms/2010.3/CLR2.0/?page=Infragistics2.Win.UltraWinGrid.v10.3~Infragistics.Win.UltraWinGrid.UltraGridRow~Expanded.html
The initialize sort of events give you the flexibility to choose on which particular state of initializing UltraGrid object you would like to add customized code that has the opportunity to change the default state of any UltraGrid component. However, there is a difference between InitializeDataRow and InitializeRow events. The first event is related to the underlying data’s initialization and the second event is related to the UltraGrid’s rows before being drawn. In the general case, all data sort of events are connected to the data source and all non-data events are related to the UltraGrid itself.
Using the LoadOnDemand option, you could apply the appearance inside the InitializeRow event, that would allow you to set different appearance on each row before its being drawn, based on whatever condition you might think of.
Please let me know if you have any additional questions.
Thanks for the response. I have set the load default to preloaded and yet I have to do some value based formatting. Currently, I am trying to apply, styles to headers, but they are being partially applied...Meaning that the first I do:
gridColumn.Header.Appearance.BackColor = Color.Green;
gridColumn.Header.Appearance.ForeColor = Color.White;
But, on rendering, I can only see the Fore Color being applied and background color is not applied. Is it because of the fact that I have not assigned the appearance instance at the once? In the hind sight, is it happening that when I apply ForeColor, by default the back ground color is reset?
Also, to note is the fact that I am doing conditional formatting of the headers by looping through all the grid columns. I have tried making modifications to one the samples provided by Infragistics and it worked there. But that is not working for me...
If I am not doing a LoadOnDemand, can I still use the RowInitialize event provided by UltraGrid? The problem is, I have the data preloaded and I also have creation filters. Now if I have to change the pattern to LoadOnDemand, there are quite a few tweaks and last time I checked, I was not able to apply Formatting to Column Headers in virtual mode with LoadOnDemand property set as it was firing the initialize events prematurely or I was not handling the stuff properly.
Thank you for your feedback.
Please find bellow answers to your questions:
Is it because of the fact that I have not assigned the appearance instance at the once? – no, this should not be the reason why back color is not applied to your grid columns’ headers. Most probably you are changing the back color at some other place in your application. So please check this. As you wrote, you have tested this code with some of our sample and it works correctly.
In the hind sight, is it happening that when I apply ForeColor, by default the back ground color is reset? – no, when you set the back color it could be reset if you reset it at some point in your application. The grid does not reset automatically appearances which you have applied.
If I am not doing a LoadOnDemand, can I still use the RowInitialize event provided by UltraGrid? – yes you can. Actually InitializeRow event fires each time a row is initialized, e.g. when the row is initially loading data or when the row is refreshed.
Now if I have to change the pattern to LoadOnDemand, there are quite a few tweaks and last time I checked, I was not able to apply Formatting to Column Headers in virtual mode with LoadOnDemand property set as it was firing the initialize events prematurely or I was not handling the stuff properly – without sample application I cannot be sure if you are or are not handling the stuff properly. So if you can provide me a small sample project I will investigate this further.
One more point – another possible reason for grid not applying back color could be if OS themes override it. Please try to set UseOsThemes property of your grid to false and let me know what the result is. You may use code like this:
this.yourUltraGrid.UseOsThemes = DefaultableBoolean.False;
Thank you for using Infragistics Controls.
Thanks for the detailed explanation. I have implemented the functionality in the non virtual mode...i.e., Preloaded mode. Also, I am able to see the Headers properly and as desired now...The problem was not the following...
but it was
this.yourUltraGrid.HeaderStyles = Headerstyle.standard
the style was set to default earlier.
I shall get back to u in case I have more troubles...