Hi, I'm playing around to find the best approach to display my task schedule in win grid.
In the first column down, employees should be displayed. To the right, every column stands for one day containing the working task for one employee. My business object has therefore two lists of objects: One list of objects A (employe plans), and every object A has a list of object B (tasks per days).The same day can have more than one task.
Is it possible to bind my business object directly to grid? How I can achieve that the days are generated to columns not rows (pivot) ?
Another approach I'm thinking about is to use UltraDataSource and setup bands and columns from code depending of my business object.
Thanks for any suggestions.
Markus
Hi Markus,
The grid doesn't have any built-in functionality to pivot the data. It only displays the structure the data source gives it.
I'm not really sure I get the exact picture of what you want to do here, though. So you might be able to achieve what you want using CardView or maybe using some unbound columns. Since I don't understand it, it's hard to say if it can be done.
Your idea of using UltraDataSource for the grid's structure is a good one. The UltraDataSource can act as a sort've intermediary between the grid and the data. You can even load the data on-demand by handling events of the UltraDataSource like CelDataRequested.
Hi Mike,
the basic problem seems that no pivot functionality is provided and therefore I can not bind the grid columns to a property of my business object.
At the moment I'm playing with two scenarios. Scenario 1 is that just the employee column is bound directly to my business object property and in the Initialize_Layout event I add unbound columns for every day to the grid.
Scenario 2 is to use the UltraDataSource and setup the band and columns of the UltraDataSource depending on my business object and then bind it to the grid. In both scenarios I have to trigger changes of the data in the grid to update my domain object manually by code.
This task can maybe done more convenient using UltraDataSource? Do you have a complete sample project of using the UltraDataSource somewhere ? If so, please give me the link.
Thanks. Markus
the UltraDataSource is confusing me. I define the data structure of the dataSource (3 bands and columns in each band). After that I bind the dataSource to the grid -> Initialize_Layout event of the grid is fired. So far as expected.
After that data rows are added to the dataSource. The dataSource event RowAdded is called right know when the row is added. But the Initialize_row event of the grid is not added immediatly. It is called "later"? How is the Initialize_row event triggered?
How are the events of the ultradataSource and grid working together? User should be able to add, remove, change copy, paste, .......cell data in the grid. Which events to trigger?
Another problem is that I have different type of rows. I can tag new rows when adding to the ultraDataSource, but in the Initialize_Row event of the grid, the tag information is lost. Do I have any possibility to get the ultraDataRow associated by the UltraGridRow? Just by indexof the bands row collection?
And last but not least: how to track changes? Trigger change events and set persistent state in the data?
Thanks for your help.
mac_swit said:After that data rows are added to the dataSource. The dataSource event RowAdded is called right know when the row is added. But the Initialize_row event of the grid is not added immediatly. It is called "later"? How is the Initialize_row event triggered?
When you add a row to the UltraDataSource (or any IBindingList data source), the data source sends a notification through the IBindingList interface that something has changed. Any bound controls, like the grid, watch for this notification. But the grid doesn't necessarily respond to this notification synchronously. Responding to every notification immediately would lock up your whole application any time your data source underwent a lot of changes at once.
So the grid just tracks that something has changed and then it updates itself the next time it paints. So that's when InitializeRow will fire.
mac_swit said:Another problem is that I have different type of rows. I can tag new rows when adding to the ultraDataSource, but in the Initialize_Row event of the grid, the tag information is lost. Do I have any possibility to get the ultraDataRow associated by the UltraGridRow? Just by indexof the bands row collection?
The UltraGridRow exposes a ListObject property, which returns the underlying data object in the data source - in this case, an UltraDataRow.
mac_swit said:And last but not least: how to track changes? Trigger change events and set persistent state in the data?
I'm afraid I do not understand your question.
Hello Mike,
Trigger changes: I mean if the user makes changes to the data in the grid. For grids bound to a dataSet, I can select the changes from the dataSet and update it by the table adapter. In this case of binding to ultraDataSource do I have to trigger the cellDataChange events and update my business object and setting some persitient state manually (changed, new, deleted)? Which events to trigger (grid or ultraDataSource) for that?
When the user updates a cell in the grid, then the grid will automatically write that data to the UltraDataSource (or whatever DataSource it is using) based on the UpdateMode property. By default, the grid saves the changes to the data source any time you move out of a cell or the grid loses focus.
UltraDataSource is intended to allow you to build the data manually. It's not really designed to work with a back end (database). So it does not track changes like a DataTable or DataSet does. If you want to track changes, you would have to do so yourself. I recommend using AfterCellUpdate or AfterRowUpdate events. You may need to handle the BeforeRowsDeleted event if you are allowing your users to delete rows.
Thanks or the information Mike.
If I have more questions, I will reopen the post.
Thank you. Markus