I have a requirement to Load/Populate Ondemand hierarchical DataGrid.(Detail grid should be shown on RowClick)
I have searched the forum but every example i found is building hierarchical gridview by using the DataSet.
But i want to do this by Using DataTable / Querying the Database.
How can i achieve the above stated requirement.
Please provide any example.
10 Answers, 1 is accepted
The details regarding dynamic loading for child data is described at the link below. While the document has two references to a dataset, the binding is actually to a datatable. Once you load the initial data into the datasource of the datagrid object, you can leverage the RowSourceNeeded event to populate the child rows for the row being expanded. It also appears you need to populate the child template ahead of time. In the sample they provide, you would leverage the RowSourceNeeded to perform you query and load the data into the child template.
The help article that Jesse referred is the appropriate solution for loading on demand in RadGridView. You can also refer to our Demo application >> GridView >> Hierarchy >> Load on demand example which is quite useufl on this topic. The Demo application can be found in the installation folder of the suite which is usually located at the following path:
C:\Program Files (x86)\Progress\Telerik UI for WinForms R3 2019\Examples\QuickStart\Bin
@Jesse, I have also updated your Telerik points for community effort.
If you need any further assistance please don't hesitate to contact me.
Dess | Tech Support Engineer, Sr.
I have setup grid view according to the information and my own logic, but i have some issues,
MasterTemplate populated, Child is not Populating.
What I'm doing is.
radGridView1_RowSourceNeeded is not called on clicking [+]
Please check what I'm doing wrong.
I have debug my code, both the tables with data are available in the dataset.
I think I'm Doing something wrong with creating relation between tables.
Just from a quick glance, you are not adding the relationship to the dataset (ds.Relations.Add). You are also setting the fieldname on each child template column even though you are not binding a datasource to it, those should probably be removed.
Also, I thought you weren't using a dataset for this. You can leverage the data passed to the event to get the source row data. This wouldn't require you to configure the dataset or relationship stuff.
Additionally, you are also missed setting the HierarchyDataProvider. You should cast the ChildTemplate to a variable then set the HierarchyDataProvider and wire the event.
Here is a working example using only datatables and no dataset.
Thank a lot Jesse.
By adding these 2 lines, GridView working now.
childTemplate.HierarchyDataProvider = new GridViewEventDataProvider(childTemplate);
Thank you again.
Perfect solution. This what i require, exactly according to my requirement.
Populating data without using DataSet Object.
Thank you Jesse. You Make my day.
I have an other question.
I have to pass this Data (1 Master and linked detail not all the Data in the Grid) as parameter on double click Masterview row.
I can do this using single template gridview, But how to loop through only child rows of Clicked Master row.
Thank you for the community effort in this thread. I have rewarded you with Telerik points for this.
Note that each row from the parent level contains ChildRows collection which will give you access to the respective hierarchy rows on the second level. Thus, you can extract just the relevant child records for a certain parent.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Dess | Tech Support Engineer, Sr.