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 Self-Reference Client-Side APIs.
To expand/collapse Self-Reference row
- Drag WebGrid instance into the WebForm.
- Add a client side function. Use ExpandSelfRefRow() to expand
self-reference row and CollapseSelfRefRow() to collapse self-reference
row.
function ToggleExpandCollapse()
{
// retrieves WebGrid's object
var grid = ISGetObject("WebGrid1");
var selectedObject = grid.GetSelectedObject(); // return object of type SelectedObject
if (selectedObject != null)
{
var selectedRow = selectedObject.ToRowObject(); // return WebGridRow object
if (selectedRow.SelfRefExpanded)
{
selectedRow.CollapseSelfRefRow(); // collapse self reference row
}
else
{
selectedRow.ExpandSelfRefRow(); // expand self reference row
}
}
else
{
alert ("Please select a row first.");
}
return true;
}
|
- Run the project.