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!
Hi Tom,
No, you can't show multiple islands of child rows without the parent rows. This wouldn't make sense.
Unless you just want to show the entire list of child rows, in which case, you would bind the grid to the child table, not the child relationship.
Nevermind. I was able to accomplish this using an unrelated (e.g. no DataRelation link) DataView for the details. I would then apply a RowFilter on the DataView based on the selected rows in the master UltraGrid.
Is it possible to have the details grid show all the rows visible in the master grid? Currently it only shows the active row. I would like the details to show the associated details for all master rows (if no rows are selected). If one or more rows are selected, then I would like to show the details for only those rows. Additionally, if the user filtered rows I would like to exclude the details for those rows.Any ideas on how to accomplish this?
Is it possible to have the details grid show all the rows visible in the master grid? Currently it only shows the active row. I would like the details to show the associated details for all master rows (if no rows are selected). If one or more rows are selected, then I would like to show the details for only those rows. Additionally, if the user filtered rows I would like to exclude the details for those rows.
Any ideas on how to accomplish this?
You can set the ViewStyle of the grid to Single to prevent it from displaying the child data.
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