WebGrid provides a set of comprehensive client side API to let developers extend the Grid for their own use.
In this topic, you will learn how to use several hierarchical Client-Side APIs.
To obtain parent row's KeyValue in WebGrid
In hierarchical grid scenario, we can get parent row's KeyValue from child table.
This topic will show you how to obtain parent's row KeyValue.
- Drag WebGrid instance into the WebForm.
- Add a client side function.
-
JavaScript Copy Code function GetParentRow() { var grid = ISGetObject("WebGrid1"); var selObj = grid.GetSelectedObject(); var row = selObj.GetRowObject(); if (row.Table.IsRootTable) alert("Please select a child row"); else { var parentRow = row.GetParentRow(); // get the parent row of this child alert("The parent row of this order is: " + parentRow.KeyValue);
}
}
To expand/collapse WebGrid's child row
Use ExpandChildRow function to expand/collapse WebGrid child row in client side.
This topic will show you how to expand/collapse WebGrid's child row.
- Drag WebGrid instance into the WebForm.
- Add a Client-Side function.
-
JavaScript Copy Code function expandChildRow()
{
var WebGrid1 = ISGetObject(controlId);
var row = WebGrid1.RootTable.GetRowByKeyValue("ANATR");
row.ExpandChildRow(true);
return true;
}function collapseChildRow()
{
var WebGrid1 = ISGetObject(controlId);
var row = WebGrid1.RootTable.GetRowByKeyValue("ANATR");
row.CollapseChildRow(true);
return true;
}
Other Resources
Walkthrough Topics
How-to Topics