Hi @ all,
is there a way to load the childbands dynamical for every single row ?
So maybe if the user double_clicks on a parent row in a Grid, the childrows will be loaded from DB and connected to that parentrow. But not for all rows in the grid, only for the one clicked (or the selected ones at click).
I don't see any way to do that with the UltraGrid, because a Relation over two tables will be load every childs !?!
Hi Nixa.
I have done this in a VB.NET project some time ago. When the user clicks on the + of a parent row (master table) the child rows from 2 detail tables are loaded and displayed. If the child rows have allready been loaded nothing happens. I have done this in the following way:
Private Sub ugArtikelstamm_BeforeRowExpanded(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableRowEventArgs) Handles ugArtikelstamm.BeforeRowExpanded Dim dr As DataRow
If e.Row.ListObject Is Nothing Then Exit Sub
dr = CType(e.Row.ListObject, DataRowView).Row ' get selected master record If dr.GetChildRows("FK_LinieA").Length = 0 Then ' child allready loaded? Me.taLinieA.FillByArticleNo(Me.dsModul.tblLinieA, CInt(e.Row.Cells("Artikel_Nr").Value)) End If If dr.GetChildRows("FK_LinieB").Length = 0 Then Me.taLinieB.FillByArticleNo(Me.dsModul.tblLinieB, CInt(e.Row.Cells("Artikel_Nr").Value)) End If dr = Nothing End Sub
What you need is a dataset with the corresponding relations from master to detail tables. You also need a method in the detail table where you can load records based on the criteria of the master record. In my example a article number is used. In your code you only have to load the data for the master table. Do not load any data in the detail table. If the load operation can take some time you can set a waitcursor in the BeforeRowExpanded() event and reset it to default in the AfterRowExpanded() event.
Hope this helps a little bit.
Ralf
Ralf,
This is not working for me. Were you using the UltraDataSource, or straight DataSet? In your code, what is the taLinieA object? I am assuming table adapter? Here is my code:
void gridTasks_BeforeRowExpanded(object sender, Infragistics.Win.UltraWinGrid.CancelableRowEventArgs e) {
try {
dsCircuitTasks.tblCircuitTasksRow row = ((DataRowView)e.Row.ListObject).Row as dsCircuitTasks.tblCircuitTasksRow;
dsCircuitTasks.tblCircuitOverrideTasksDataTable tbl =
((dsCircuitTasks)dsCircuitTasksBindingSource.DataSource).tblCircuitOverrideTasks;
_graphingUtilInstance.fill_child_data(row.id, tbl);
}
catch (Exception ex){
void ckt_Load(object sender, EventArgs e) {
_graphingUtilInstance = TaskSystem.Data.
GraphingUtil.CreateInstance();
dsCircuitTasksBindingSource.DataSource =
_graphingUtilInstance.search_for_data();
catch (Exception ex) {
MessageBox.Show(ex.Message, "Circuit", MessageBoxButtons.OK,
MessageBoxIcon.Information);
Hello.
Nice if it works now. That post was a long time ago and I did not expect to get any emails regarding to it. Does it work the way you expected it?
Sorry for my worst english.
Nevermind. I figured it out. I had the foreign key defined on my child table, but didn't include that field's data in the select clause of the database query.