Hi,
I am new to ultragrid and I want to create a grid as shown in the attached figure.Please let me know the steps how can I create such grid. I am using binding source to bind the grid, please help me to know how should I manage the binding source to bind such grids.
Thanks a lot in advance. Any code sample will be highly appreciated.
Here is the image:
Hi Mike,
Thanks for your reply.
yes ..I understood the difference between behaviour of grid in terms of grid binding using hierarical datasource and flat list.
I used the same approach as suggested by you. Thank a lot .
I'm afraid I am still confused. The first image you posted here is too small for me to see what's going on.
From what I can gather, it looks like you have a hierarchical data source and you want to flatten it for the grid. I don't think that will work. The grid has no functionality to automatically flatten out the data for you. If you bind the grid to a data source with parent and child rows, then the grid will display them that way - in a hierarchy. There's no way for the grid to take a child band and make it into a set of columns in the root-level band.
You could achieve this yourself, by adding groups and unbound columns to the root band and then using the grid events like InitializeRow to copy the data from the child row(s) into the parent row cells. But I don't think that solution will work for you, because if I understand correctly, you may have multiple child rows under each parent row and the grid cannot duplicate the root-level rows for you.
The simplest thing for you to do here is to not bind the grid directly to your list of objects, but instead create some other data source, like a DataTable or UltraDataSource and populate it with a flat list of data that represents what you want.
The data source I assigned to the grid is a list of class which contains some properties and one property is again a list of some class which have some properties.
Example:
Class1 {
String Property1;
String Property2;
List<Class2> Property3;
}
Class2{
string Property21;
string Property22;
string Property23; -- This property is shown as month(Group Header)
here is the sample data for the class
Now I am binding the List<Class1> to the grid and I am able to create the following structure but not able to add columns under Month groups.
And here is the final grid which I want to create:
I'm sorry, I'm still not really sure what you are asking. You need to create a data source with the data structure you want and bind it to the grid. How you do that is up to you, and there are many different types of data sources you can use.
The fact that the data structure may vary doesn't matter to the grid. You have to establish the structure you want first, before you bind the grid.
Thanks mike for your reply.
The problem is that the columns coming under months are dynamic, means sometime it may be 2 like Jan-11,Feb-11 some sometime it may be 4 to 5 and columns under each months are stattic means always there will be 3 columns under each month.
Out Data is coming in xml format and I have to create a class and corresponding properties for that.
Here is the example of the data coming in xml format:
<ItemList> <Item> <Col1>value1</Col1> <Col2>value2</Col2> <Col3>value3</Col3> <MonthList> <Month> <C>Jan-11</C> <C1>somevalue</C1> <C2>somevalue</C2> <C3>somevalue</C3> </Month> <Month> <C>Feb-11</C> <C1>somevalue</C1> <C2>somevalue</C2> <C3>somevalue</C3> </Month> </MonthList></Item><Item>................ </Item>
</ItemList>
Here I have shown only 2 months data. It may be of 3 to 12 months. Generally it varies from 1 to 12 number.
So please help me how can I proceed with it.
Thanks in advance.