I have a WebHierarchicalDataGrid with the selection behavior enabled. It's set to select the row. In the html definition, the behaviors tag looks like this:
<Behaviors> <ig:Selection CellClickAction="Row" RowSelectType="Single" SelectedCellCssClass="RowHighlight"> <SelectionClientEvents RowSelectionChanged="whdg_RowSelectionChanged" /> </ig:Selection></Behaviors>
I'm trying to access the selected row from javascript when a button is clicked. The code for that function is:
var grid = $find("<%=myGrid.ClientID%>");
var selectedRows = grid.get_behaviors().get_selection().get_selectedRows();
However the code fails. get_behaviors() does not appear to be a method on the grid object. Am I missing something here? Everything I search for just says to use grid.get_behaviors(), but I can't make it work.
The selection behavior is working at run-time and my RowSelectionChanged event is firing and working correctly. I'm using NetAdvantage 2012.1 CLR 4x.
Any help is appreciated.
I believe I found the answer. It looks like for Hierarchical grids, you must call get_gridView().
So the solution is: var selectedRows = grid.get_gridView().get_behaviors().get_selection().get_selectedRows();
Hello Nick,
Yes this is the solution, same applies if you want to access them server side.
Example:
this.WebHierarchicalDataGrid1.GridView.Behaviors.Selection.CellClickAction =
CellClickAction.Row;
I am glad that you've managed to find the answer for this scenario. If I may be of further assistance, do not hesitate to contact me.