Hi,
I have an UltraWinGrid on a windows form, to which I bind a dataset to display a data.
When I click on any one of the rows by clicking the '+' symbol, I must display an indented set of at least one or more rows as a child row.
Here's my approach:
(a) Get a new dataset containing only those child rows.
(b) Create a parent child relationship constraint with the existing main dataset and bind it to the grid.
If the above approach is not the best, Please specify what can be the best approach to do this.
Thanks in advance,
Scott.
Hello,
I bind the grid to a dataset which only has one table with no child tables. Now inside the mygrid_BeforeRowExpanded event, I create a new dataset which has the same data as the current dataset plus child relation constraint by using DataRelation. Now the dataset has two tables. One is parent and the other is child with a unique key.
I now call mygrid.DataSource = newdataset;
When I execute it and try clicking the '+' sign this does not show any child rows. It only shows the basic grid with parent rows.
Am I missing any thing. Please help.
Thanks,
Adding to the above, If I place the code in a Button click event, it properly displays the parent child as a related view on the Grid. However, if i do this on a BeforeRowExpanded event, it does not.
Hi Scott,
I'm a little confused by what you are trying to do. If you simply want to show a hierarchy in the grid, then you can create a DataSet with two tables and a relationship and bind it to the grid. That's it... you don't have to handle events and add things in when the row is expanded.
It seems like you are jumping through hoops to make this much more complicated than it should be. Is there some reason you need to do that?
Hi Mike,
You are right. I can do that upfront. But there are millions of rows and I don't want to show all the children up front. I only want to show the Parent rows first and ONLY when you select a parent, i can see the children. I Hope that helps in understanding the issue.
Is there anyway to display a BOM a parent having children and tghe children potentially having more children within a grid
i am writting a similar solution to this and it happens to work too but i have the same problem with duplicate rows. Have you reached to a solution for this issue?
thanks,
i am trying the same thing. Could you give us more details about the correct solution?
Marova
Mike,
The child list now appears in the grid. All I did is
(a)Get the current dataset (having parent/child relation) .
(b)Add child rows to the child datatable inside it.
(c)use the statement setDataBindings(datasource,""); inside BeforeRowExpanded event.
It now shows the rows. The only issue now would be to make sure it won't add duplicate rows
again and again whenever the BeforeRowExpanded event happens.
Thanks a lot for your help Mike.
For you initial question, Yes the grid does have its datasource containing a second child table. However, it does not expand the children as there are zero rows in that table. Hope it helps.