Hi,
I was trying to use two UltraWinGrids to display a master / detail page for my offline data set. On my data set, there is a master table and child table with a relationship. On the master grid, I binded the data set with master table as the data member, and on the detail grid, I binded to the data set with child table as data memer. However, when I changes my selection in the master grid, the child grid does not change according to my selection. The child table always shows all the data from the child table. Is there anything that I'm doing wrong? Can someone provide some samples? Thanks!
This sounds like an issue with how you've databound the two WinGrid objects.Let's assume you have a DataSet called "ds" with two DataTables, "dtParent" and "dtChild", connected with a DataRelation called "Parent_Child". Let's also assume that your two grids are called "ultraGrid1" for the parent data and "ultraGrid2" for the child data.You likely have set up your databinding as follows (in C# code):this.ultraGrid1.SetDataBinding(ds, "dtParent"); // sets DataSource, DataMemberthis.ultraGrid2.SetDataBinding(ds, "dtChild");If this is true, then the results you've described are expected.To get what you're after, you need to use the .NET data binding syntax to bind your second grid such that .NET knows that the two grids need to be synchronized. You do this by using the parent table's name, and the name of the DataRelation.In the above example, the desired syntax for databinding the second grid is:this.ultraGrid2.SetDataBinding(ds, "dtParent.Parent_Child");With this, the second grid will only show the child rows relevant to the active row in the first grid.Please remember that these forums area a peer-to-peer resource to share issues and ideas with other Infragistics users. If you require official support from Infragistics for further assistance, please submit a support incident to Infragistics Developer Support from this page of our website.
I've tried this in a test project:
Private Sub frmMasterDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Connection As MySqlConnection Dim MasterAdapter As MySqlDataAdapter Dim DetailsAdapter As MySqlDataAdapter Try Me.Cursor = Cursors.WaitCursor Connection = New MySqlConnection(Me.ConnectionString) 'load master table MasterAdapter = New MySqlDataAdapter("SELECT * FROM DEPTs", Connection) MasterAdapter.FillSchema(Me.DataSet, SchemaType.Mapped, "Master") 'set the starting value to which calculate the ID column Me.DataSet.Tables("Master").Columns("ID").AutoIncrementStep = -1 Me.DataSet.Tables("Master").Columns("ID").AutoIncrementSeed = 0 MasterAdapter.Fill(Me.DataSet, "Master") 'load details table DetailsAdapter = New MySqlDataAdapter("SELECT * FROM DEPT_CONTACTs", Connection) DetailsAdapter.FillSchema(Me.DataSet, SchemaType.Mapped, "Details") 'set the starting value to which calculate the ID column Me.DataSet.Tables("Details").Columns("ID").AutoIncrementStep = -1 Me.DataSet.Tables("Details").Columns("ID").AutoIncrementSeed = 0 DetailsAdapter.Fill(Me.DataSet, "Details") 'create the parent child relation Dim dr As DataRelation dr = New DataRelation("Parent_Child", Me.DataSet.Tables("Master").Columns("ID"), Me.DataSet.Tables("Details").Columns("DEPTs_ID"), False) Me.DataSet.Relations.Add(dr) 'load data in the grid Me.UltraMaster.SetDataBinding(Me.DataSet, "Master") Me.UltraDetails.SetDataBinding(Me.DataSet, "Master.Parent_Child") Catch ex As Exception MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Finally Me.Cursor = Cursors.Default End Try End Sub
but in this way, the UltraMaster grid shows data in hierarchical view... how can I prevent this (showing the master table in a simple view)?
Are there reasons to prefer the use of 2 grids in master/details relation rather than the hierarchical view?
Thanks,
Salo