WebGrid Core Global Functions
wgGetActiveGrid |
Description Gets the currently active grid. Return Value
function GetActiveGrid()
{ var grid = ISGetObject("WebGrid1"); grid.SetFocus();
alert(wgGetActiveGrid());
}
|
wgGetGridById |
Description Gets the WebGrid instance by its ID. Parameters
Return Value
function GetGridName()
{ var grid = wgGetGridById("WebGrid1");
alert(grid.Name);
// It's highly recommended not to use
// wgGetGridById method anymore for consistency purpose // Please use ISGetObject method for future usage var grid = ISGetObject("WebGrid1");
alert(grid.Name);
} |
wgGetChildTableByRow |
Description Returns the Container element of childtable by specific row and child table name. Parameters
Return Value
function DoSelectRow()
{ // a simple hiearchical tables // Customers -> Orders // try to expand the first row first // and then use this function // in order to use wgGetChildTableByRow // the child table needs to be expanded first
var grid = ISGetObject("WebGrid1");
var wgRow = grid.GetSelectedObject().GetRowObject();
var htmlRow = wgRow.GetElement();
var chldTbl = wgGetChildTableByRow(htmlRow, "Orders"); return true; } |
wgGetCellCount |
Description Gets the cell's count of the specified row. Parameters
Return Value
function GetCellCount()
{ // a simple hiearchical tables // Customers -> Orders
var grid = ISGetObject("WebGrid1");
var wgRow = grid.RootTable.GetRow(0);
var htmlRow = wgRow.GetElement();
alert(wgGetCellCount(htmlRow)); return true; } |
wgGetCellByPosition |
Description Returns the cell HTML element based on specified row and position. Parameters
Return Value
function GetCellContents()
{ // a simple hiearchical tables // Customers -> Orders
var grid = ISGetObject("WebGrid1");
var wgRow = grid.RootTable.GetRow(0);
var htmlRow = wgRow.GetElement();
alert(wgGetCellByPosition(htmlRow, 1).innerText); return true; } |
wgGetCellByName |
Description Returns the cell HTML element based on the specified row and column's name. Parameters
Return Value
function GetCellContents()
{ // a simple hiearchical tables // Customers -> Orders
var grid = ISGetObject("WebGrid1");
var wgRow = grid.RootTable.GetRow(0);
var htmlRow = wgRow.GetElement();
alert(wgGetCellByName(htmlRow, "Country").innerText); return true; } |
wgGetCellPosByName |
Description Returns the cell's position by column's name. Parameters
cell ( string )
Return Value
function GetCellContents()
{ // a simple hiearchical tables // Customers -> Orders
var grid = ISGetObject("WebGrid1");
var wgRow = grid.RootTable.GetRow(0);
var htmlRow = wgRow.GetElement();
// return null alert(wgGetCellPosByName(htmlRow, "CustomerID")); return true; } |
wgGetRowByPosition |
Description Returns the row based on specified table and position. Parameters
Return Value
function GetRowElement()
{ var grid = ISGetObject("WebGrid1");
var htmlTbl = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE);
var htmlRowElm = wgGetRowByPosition(htmlTbl, 0);
alert(htmlRowElm.type);
return true;
} |
wgGetRowByPositionExact |
Description Gets the row based on specified exact position indexed by WebGrid internal row's position. Parameters
Return Value
// get the grid Object. // get HTML body of the table element. // get row by position exact. |
wgGetRootRow |
Description Gets the root/first row of a ColumnSet rows or PreviewRow. Parameters
Return Value
// get the grid Object.
var grid = ISGetObject("WebGrid1"); //get row element. var rowElm = grid.GetSelectedObject().GetRowObject().GetElement(); // get the root of the rows. var rootRow = wgGetRootRow(rowElm); |
wgGetColNameByCell |
Description Gets the column's name based on specified cell. Parameters
Return Value
// get the grid Object. //get the row Element from the selected object. //get the string column name with using cell element. |
wgGetSelectedObjectFromEvent |
Description Gets the wgSelectedObject from event information. Parameters
Return Value
//get the selected object from window. event.
var obj = wgGetSelectedObjectFromEvent(window.event); //get the selected object from window. event. var obj = wgGetSelectedObjectFromEvent(window.event); //get the selected object from window. event. var obj = wgGetSelectedObjectFromEvent(window.event); |
wgIsColumnSetRow |
Description Determines whether the specified row is a ColumnSet row. Parameters
Return Value
//get the object of the grid
var grid = ISgetObject("WebGrid1"); //get the selected row element var rowElm = grid.GetSelectedObject().GetRowObject().GetElement(); //check whether the row is a ColumnSet row or not. var bool = wgIsColumnSetRow(rowElm) ; |
wgGetPreviewRow |
Description Gets the row html element of a PreviewRow object. Parameters
Return Value
// get the grid object.
var grid = ISGetObject("WebGrid1"); // get the selected object row element. var rowElm = grid.GetSelectedObject().GetRowObject().GetElement(); // get the html of the preview row. var row = wgGetPreviewRow(rowElm); |
wgGetPreviewRowCell |
Description Gets the cell HTML element which contains data of the preview row. Parameters
Return Value
//get grid object
var grid = ISGetObject("WebGrid1"); //get the row element of the selected object var rowElm = grid.GetSelectedObject().GetRowObject().GetElement(); //get the preview row element var prevrow = wgGetPreviewRow(rowElm); //get the preview cell element var prevcell = wgGetPreviewRowCell(prevrow); |
wgIsValidCell |
Description Gets the valid cell. Parameters
Return Value
//get the grid object.
var grid = ISGetObject("WebGrid1"); //get the row element. var rowElm = grid.GetSelectedObject().GetRowObject().GetElement(); //get the first cell element. var cellElm = rowElm.cells[1]; //get to know whether the cell element is valid or not. var cellbool = wgIsValidCell(cellElm); |
wgIsValidClickableCell |
Description Gets the valid clickable cell. Parameters
Return Value
// get the grid Object. // get HTML row element. //get the status whether cell is valid clickable or not. |
wgIsValidRow |
Description Gets the valid row Parameters
Return Value
// get the grid Object. // get HTML row element. |
wgGetPreviewRowParent |
Description Gets the row html element of the parent row of specified preview row Parameters
Return Value
// get the grid Object. // get HTML row element. |
wgIsSameRow |
Description Determines whether row1 and row2 is in one DataRow. Parameters
Return Value
// get the grid Object. // get HTML row element. |
wgIsSameColumnSetRow |
Description Determines whether the row1 and row2 is in the same ColumnSet rows. Parameters
Return Value
// get the grid Object. // get HTML row element. |
wgIsRecordRow |
Description Determines whether the specified row is a record row Parameters
Return Value
//get the grid object
var grid = ISGetObject("WebGrid1"); //get the row element var rowElm = grid.GetSelectedObject().GetRowObject().GetElement() //get the first cell status valid or not var bool = wgIsRecordRow(rowElm); |
wgGetHierRecord |
Description Gets the child's row element from a specified row of hierarchical grid Parameters
Return Value
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{ var rec = wgGetHierRecord(rowEl); } |
wgGetRowByGroup |
Description Gets the group's row element Parameters
Return Value
function doButtonClick()
{ //get the grid object var grid = ISGetObject("WebGrid1"); //make sure the grid is grouped if (grid.RootTable.GroupedColumns.length > 0) { //get the first group row element var firstGroupRow = wgGetRowByGroup(grid.RootTable.GetElement(WG40.BODY,WG40.HTMLTABLE),0,0); alert(firstGroupRow.innerText); } } |
wgIsFilterRow |
Description Determines whether or not the row element is filter row. Parameters
Return Value
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{ var flag = wgIsFilterRow(rowEl); return true; } |
wgRemoveRow |
Description Removes a row from table element. Parameters
Return Value
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{ //get the grid object of the selected row var grid = ISGetObject(controlId); //get the table object of the selected row var table = grid.Tables[tblName].GetElement(WG40.BODY,WG40.HTMLTABLE); //remove the selected row wgRemoveRow(table,rowEl); return true; } |
wgGetGridByElement |
Description Gets the grid object of HTML element. Parameters
Return Value
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{ //get the cell element of the selected row var cell = wgGetCellByName(rowEl, "Address"); //get the grid object from the cell element var grid = wgGetGridByElement(cell); alert(grid.Id); return true; } |
wgGetTableByElement |
Description Gets the table object of table element. Parameters
Return Value
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{ //get the grid object var grid = ISGetObject(controlId); //get the table element var tbl = grid.Tables[tblName].GetElement(WG40.BODY,WG40.HTMLTABLE); //get the table object var tblEl = wgGetTableByElement(tbl); return true; } |
wgGetColumnByElement |
Description Gets the column object of column element. Parameters
Return Value
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{ //get the grid object var grid = ISGetObject(controlId); //get the table object var tbl = grid.Tables[tblName]; //get the row object var row = tbl.GetRow(0); //get the cell element var cell = row.GetCell(0).GetElement(); //get the WebGridColumn object var col = wgGetColumnByElement(cell); return true; } |
wgGetCellByElement |
Description Gets the cell object of cell element. Parameters
Return Value
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{ //get the cell element of the selected row var cell = wgGetCellByName(rowEl, "Address"); //get the WebGridCell object from the cell element var cellObj = wgGetCellByElement(cell); return true; } |
wgGetRowByElement |
Description Gets the WebGridRow object of the row element. Parameters
Return Value
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{ //get the row object var rowObj = wgGetRowByElement(rowEl); return true; } |
References
{How-to: Get row by index}
{How-to: Get row by KeyValue}
{How-to: Get a cell by index}
{How-to: Get a cell by name}
{How-to: Get a column name of the selected cell}
{How-to: Set text to a specific cell}
{How-to: Get root row of ColumnSet layout}
{How-to: Get checked rows in client side}
{How-to: Retrieve Preview Row's text}