Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Row Selection when Web Grid is Grouped by
posted

I have a web grid in the page. When user selects any row (in the normal scenario) in the grid by double click on selected row, I display the data related with this record in a form under the grid. But when I group by some column in the grid, and double click on any row of the child (nested) grid to display the data in the form, I can't identify the row where I am and nothing appears in the form.

How can I identify the selected row in a grouped by grid in a WebGrid ?

Thanks to any idea.

This is the code:

Private Sub uwgrdOC_DblClick(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.ClickEventArgs) Handles uwgrdOC.DblClick

Try

Call CaragarDetalleOC(CInt(Me.uwgrdOC.Rows(e.Row.Index).Cells.FromKey("ID").Text))

Catch ex As Exception

End Try

End Sub

Private Sub ConfigurarGrid(ByRef UltraGrid As Infragistics.WebUI.UltraWebGrid.UltraWebGrid)

UltraGrid.DisplayLayout.RowSelectorsDefault = Infragistics.WebUI.UltraWebGrid.RowSelectors.Yes

UltraGrid.DisplayLayout.CellClickActionDefault = Infragistics.WebUI.UltraWebGrid.CellClickAction.CellSelect

UltraGrid.DisplayLayout.SelectTypeCellDefault = Infragistics.WebUI.UltraWebGrid.SelectType.Extended

UltraGrid.DisplayLayout.SelectTypeRowDefault = Infragistics.WebUI.UltraWebGrid.SelectType.Extended

End Sub

 

Parents
  • 45049
    posted

    When you group the grid, your data rows are no longer direclty in the grid's Rows collection.  Instead, this contains one or more GroupByRow objects, one for each group.  Each GroupByRow object either contains another set of GroupByRow objects (if you have multiple levels of grouping) or the UltraGridRow objects that represent your data.

    This means that you can't retrieve the row by its index.  The "index" will represent where the double-clicked-on row exists in its parent collection, and won't match what's in the grid.

    To identify the row, you may be able to make use of the ClickEventArgs of the DblClick event.  Take a look at e.Row - if this is not null, then you've double-clicked on a row.  So, I'd replace the Try block in your statement with the following few lines:

    If Not e.Row Is Nothing Then
        Try
            Call CaragarDetalleOC(CInt(e.RowCells.FromKey("ID").Text))
        Catch ex as Exception
        End Try
    End If

Reply Children