Hi
i have a hirechal grid which is bound to dataset when the grid is loaded at from load its in expanded state but once i saved some data from textboxes and refresh the datasource of the grid the rows becomes collapse and moreover i won't be able to expand the MASTER RECORD when i click on the plus sign
here is the code snippet i used
myDataSet = New DataSet("myDataSet")
Dim myParam As New ArrayList()
Dim myStruct As sprocParam
Dim obj As New MMDAC()
myStruct.paramName = "@DETC_SH_ID"
myStruct.paramType = OleDbType.VarChar
myStruct.paramSize = 10
myStruct.paramValue = o_7501.SHC_ID
myParam.Add(myStruct)
dtInvNo = obj.ExecuteSelectStoredProc("usp_GetDistinctInvoiceNoFromLineItemDetail", myParam)
myDataSet.Tables.Add(dtInvNo)
myDataSet.Tables(0).TableName = "InvNo"
myParam.Clear()
''Now get the Invoice_line_Details from line_item_details
myStruct.paramName = "@Param"
myStruct.paramType = OleDbType.VarChar
myStruct.paramSize = 100
myStruct.paramValue = " DETC_SH_ID='" & o_7501.SHC_ID & "'"
myParam.Add(myStruct)
dtInvDetails = obj.ExecuteSelectStoredProc("usp_AllLineItemDetail_Select", myParam)
myDataSet.Tables.Add(dtInvDetails)
myDataSet.Tables(1).TableName = "InvDetails"
Dim dr As New DataRelation("InvHeaderToInvDetails", dtInvNo.Columns("InvNo"), dtInvDetails.Columns("DETC_InvNo"))
myDataSet.Relations.Add(dr)
' Reduce flicker
Me.gridDataBoundGrid1.BeginUpdate()
Me.gridDataBoundGrid1.DataMember = "InvNo"
Me.gridDataBoundGrid1.DataSource = myDataSet
'setting grid properties on form load only
If blnFormLoad = False Then
' cache grid model and binder
Me.gridModel = Me.gridDataBoundGrid1.Model
Me.gridBinder = Me.gridDataBoundGrid1.Binder
Dim hlInvoice As GridHierarchyLevel = gridBinder.RootHierarchyLevel
'If blnFormLoad = False Then
hlInvoice_Detail = gridBinder.AddRelation("InvHeaderToInvDetails")
'End If
'''If blnFormLoad = False Then
gridModel.Options.AllowSelection = GridSelectionFlags.AlphaBlend Or GridSelectionFlags.Row Or GridSelectionFlags.Column Or GridSelectionFlags.Keyboard Or GridSelectionFlags.Shift
gridModel.Options.AllowDragSelectedCols = False
AddHandler Me.gridDataBoundGrid1.PrepareViewStyleInfo, AddressOf gridDataBoundGrid1_PrepareViewStyleInfo
Dim standard As GridStyleInfo = gridModel.BaseStylesMap("Standard").StyleInfo
standard.ShowButtons = GridShowButtons.ShowCurrentRow
Dim progressDialog As New DelayedStatusDialog(gridModel)
gridModel.OperationFeedbackListener = progressDialog
gridDataBoundGrid1.AllowResizeToFit = False
'Handling the Columns
Dim i As Integer
For i = 0 To gridModel.ColCount
gridModel.ColWidths(i) = 0
Next
gridModel.ColWidths(1) = 100 '"InvNo"
gridModel.ColWidths(2) = 100 '"DETN_LineNo"
Dim clmnStyle_rCode As GridBoundColumn = hlInvoice_Detail.InternalColumns("DETN_LineNo")
clmnStyle_rCode.HeaderText = "Line No"
clmnStyle_rCode.MappingName = "DETN_LineNo"
'clmnStyle_rCode.StyleInfo.HorizontalAlignment = Syncfusion.Windows.Forms.Grid.GridHorizontalAlignment.Right
gridModel.ColWidths(3) = 100 '"DETC_HSCode"
clmnStyle_rCode = hlInvoice_Detail.InternalColumns("DETC_HSCode")
clmnStyle_rCode.HeaderText = "HS Code"
clmnStyle_rCode.MappingName = "DETC_HSCode"
gridModel.ColWidths(4) = 100 '"DETC_PartNo"
clmnStyle_rCode = hlInvoice_Detail.InternalColumns("DETC_PartNo")
clmnStyle_rCode.HeaderText = "Part No"
clmnStyle_rCode.MappingName = "DETC_PartNo"
gridModel.ColWidths(5) = 200 '"DETC_ShortDesc"
clmnStyle_rCode = hlInvoice_Detail.InternalColumns("DETC_ShortDesc")
clmnStyle_rCode.HeaderText = "Description"
clmnStyle_rCode.MappingName = "DETC_ShortDesc"
gridModel.ColWidths(6) = 100 '"DETN_InvQty"
clmnStyle_rCode = hlInvoice_Detail.InternalColumns("DETN_InvQty")
clmnStyle_rCode.HeaderText = "Invoice Qty"
clmnStyle_rCode.MappingName = "DETN_InvQty"
''Dim lastRow As Integer = Me.gridDataBoundGrid1.ViewLayout.LastVisibleRow
''gridModel.ColWidths.ResizeToFit(GridRangeInfo.Cells(2, 0, gridModel.ColCount, lastRow), GridResizeToFitOptions.IncludeHeaders Or GridResizeToFitOptions.NoShrinkSize Or GridResizeToFitOptions.ResizeCoveredCells)
hlInvoice.RowStyle.BackColor = Color.FromArgb(192, 201, 219)
hlInvoice_Detail.RowStyle.BackColor = Color.FromArgb(255, 255, 245)
Me.gridDataBoundGrid1.HighlightCurrentColumnHeader = True
' Enable SelectAll mode for current cell (looks better)
gridModel.Options.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.WhenGridActive
gridModel.Options.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll
' Move current cell to top-left corner.
Me.gridDataBoundGrid1.CurrentCell.MoveTo(gridModel.Rows.HeaderCount + 1, gridModel.Cols.HeaderCount + 1)
' Resize rows option
gridModel.Options.ResizeRowsBehavior = GridResizeCellsBehavior.ResizeSingle Or GridResizeCellsBehavior.OutlineBounds Or GridResizeCellsBehavior.OutlineHeaders
gridModel.Options.ResizeColsBehavior = GridResizeCellsBehavior.ResizeSingle Or GridResizeCellsBehavior.AllowDragOutside Or GridResizeCellsBehavior.OutlineBounds Or GridResizeCellsBehavior.OutlineHeaders
' Set fond bold for standard column headers
Dim gsiHeader As GridStyleInfo = gridModel.BaseStylesMap("Header").StyleInfo
gsiHeader.Font.Bold = True
gsiHeader.Enabled = True
Dim gsiStandard As GridStyleInfo = gridModel.BaseStylesMap("Standard").StyleInfo
gsiStandard.Interior = New BrushInfo(Color.FromArgb(237, 240, 246))
gsiStandard.TextColor = Color.FromArgb(0, 21, 84)
Me.gridDataBoundGrid1.VerticalThumbTrack = True
' Grid will repaint ittself later.
'Me.gridDataBoundGrid1.ExpandAll()
'If blnFormLoad = False Then
Me.gridDataBoundGrid1.ExpandAll()
'End If
AddHandler Me.gridDataBoundGrid1.ScrollInfoChanged, AddressOf Me.gridDataBoundGrid1_ScrollInfoChanged
End If
Me.gridDataBoundGrid1.EndUpdate()
AD
Administrator
Syncfusion Team
July 9, 2003 10:50 PM UTC
Can you post asamle program (maybe using the northwind database) showing the problem so we can debug things here?
In this forum thread, http://www.syncfusion.com/forums/message.asp?MessageID=5434, there are a couple of samples showing how you can update rows in a hierarchicl grid as well as insert and remove rows.