WebGridRow Properties
Table | Description Gets the WebGridTable to which the row belongs. ValueType object (WebGridTable) Default Value - |
SubTable | Description Gets the SubTable of the current row. ValueType object (WebGridSubTable) Default Value - |
ParentTableRow | Description Gets the parent table row that owns this row. ValueType object (WebGridRow) Default Value - |
ParentRow | Description Gets the ParentRow of the current row. ValueType object (WebGridRow) Default Value - |
KeyValues | Description Gets the key values of composite data key fields. ValueType string Default Value - |
ChildrenLoaded | Description Returns whether children row's has been loaded. ValueType boolean Default Value - |
Expanded | Description Gets or sets a value that indicates whether the row is expanded. ValueType boolean Default Value - |
Grid | Description Gets the WebGrid object that owns the row. ValueType object (WebGrid) Default Value - |
Parent | Description Gets the parent row that owns this row. ValueType object (WebGridRow) Default Value - |
Position | Description Gets or sets the ordinal position of the row object. ValueType integer Default Value - |
Selected | Description Determines whether the current row is selected or not. ValueType boolean Default Value - |
Visible | Description Specifies whether the row should be rendered. ValueType boolean Default Value - |
Type | Description Gets the type of the row. ValueType string Default Value - |
DataChanged | Description Returns whether row's data has been changed. ValueType boolean Default Value - |
KeyValue | Description Gets the key values of composite data key fields. ValueType string Default Value - |
ForceNoEdit | Description Determines whether this row will be forced to not allow editing. ValueType boolean Default Value - |
Checked | Description Determines whether the current row is checked. ValueType boolean Default Value - |
Name | Description The Name of the item in its collection. ValueType string Default Value - |
GroupRowText | Description Gets the GroupRow text. ValueType string Default Value - |
GroupExpanded | Description Determines whether the GroupColumns of this row has been expanded. ValueType boolean Default Value - |
ChildExpanded | Description Determines whether the Child Rows of current row is expanded. ValueType boolean Default Value - |
SelfRefLevel | Description Gets the SelfReference level. ValueType integer Default Value - |
IsSelfRefRow | Description Determines whether current row is SelfReference type row. ValueType boolean Default Value - |
SelfRefRowCount | Description Gets the number of the child SelfReference row. ValueType integer Default Value - |
SelfRefParentValue | Description Gets the SelfReference parent value. ValueType integer Default Value - |
WebGridRow Methods
GetNextRow |
Description Gets the next WebGridRow object. Parameters - Remarks Return Value
Samples
function CheckRows()
{ // obtain grid's object var grid = ISGetObject("WebGrid1");
// obtain WebGridRow object of 6th row
var row = grid.RootTable.GetRow(5); for (var i=0; i<5; i++) { // set the row as checked row.Check();
// obtain the next WebGridRow object
row = row.GetNextRow(); } } |
GetPreviousRow |
Description Gets the previous WebGridRow object. Parameters - Remarks Return Value
Samples
function CheckRows()
{ // obtain grid's object var grid = ISGetObject("WebGrid1");
// obtain WebGridRow object of 11th row
var row = grid.RootTable.GetRow(10); for (var i=0; i<5; i++) { // set the row as checked row.Check();
// obtain the previous WebGridRow object
row = row.GetPreviousRow(); } } |
Update |
Description Performs row update. Parameters
Remarks Return Value
function UpdateRow()
{ var grid = ISGetObject("WebGrid1");
// get WebGridRow object by key value.
var row = grid.RootTable.GetRowByKeyValue("SPLIR"); var cells = row.GetCells(); // select this row for focus row.Select();
// change contact title cell to Owner
cells.GetNamedItem("ContactTitle").SetText("Owner", true); // perform Update row.Update(); alert("ContactTitle of this row has been changed to 'Owner'"); } |
Delete |
Description Performs row delete. Parameters
Remarks
function DeleteRow()
{ var grid = ISGetObject("WebGrid1");
// get WebGridRow object by key value.
var row = grid.RootTable.GetRowByKeyValue("VINET"); // select this row for focus row.Select(); alert("Click OK to delete this row."); // delete this row row.Delete(); alert("Customer 'VINET' has been deleted!"); } |
Validate |
Description Invokes OnRowValidate client side event for the specified RowElement. Parameters - Remarks
function DoPerformRowValidate()
{ var grid = ISGetObject("WebGrid1");
var firstRow = grid.RootTable.GetRow(0);
// Validate() method will automatically invoke
// OnRowValidate client side event // Please attach a client side event // on OnRowValidate before invoking this method firstRow.Validate(); return true; } |
IsDirty |
Description Determines whether the current row is dirty. Parameters - Remarks
Samples
function SelectNewRow()
{ var grid = ISGetObject("WebGrid1");
// return the html element of the newrow
var newRowElement = grid.RootTable.GetNewRow();
// convert to WebGridRow object
var newRow = grid.RootTable.ToRowObject(newRowElement); // select new row newRow.Select(); // populate cells var cells = newRow.GetCells();
// activate edit cell on City cell, instead of first cell
cells.GetNamedItem("City").ActivateEdit();
// set the CustomerID cell's text to NEWCUST,
// 2nd parameter is true indicating that the value is same as the text. cells.GetNamedItem("CustomerID").SetText("NEWCUST", true); cells.GetNamedItem("Address").SetText("New Address", true); // indicates that this row's data has been changed. newRow.SetDataChanged(); // check whether the NewRow is dirty or not alert( newRow.IsDirty() );
// sets the row's status as edited,
// as if user has typed inside the cell. grid.MarkEdit(); } |
SetDataChanged |
Description Indicates that the current row's data has been changed. Parameters - Remarks
function SelectNewRow()
{ var grid = ISGetObject("WebGrid1");
// return the html element of the newrow
var newRowElement = grid.RootTable.GetNewRow();
// convert to WebGridRow object
var newRow = grid.RootTable.ToRowObject(newRowElement); // select new row newRow.Select(); // populate cells var cells = newRow.GetCells();
// activate edit cell on City cell, instead of first cell
cells.GetNamedItem("City").ActivateEdit();
// set the CustomerID cell's text to NEWCUST,
// 2nd parameter is true indicating that the value is same as the text. cells.GetNamedItem("CustomerID").SetText("NEWCUST", true); cells.GetNamedItem("Address").SetText("New Address", true); // indicates that this row's data has been changed. newRow.SetDataChanged();
// sets the row's status as edited,
// as if user has typed inside the cell. grid.MarkEdit(); } |
IsMarkedEdit |
Description Determines whether the current row has been marked edit. Parameters - Remarks Return Value
Samples
function CustomFunction()
{ var grid = ISGetObject("WebGrid1"); var wgRow = grid.GetSelectedObject().GetRowElement();
alert(wgRow.IsMarkedEdit());
return true;
}
|
CancelChanges |
Description Perform CancelChanges to any row modification Parameters - Remarks Return Value
Samples
function CustomFunction()
{ var grid = ISGetObject("WebGrid1"); var wgRow = grid.GetSelectedObject().GetRowElement();
wgRow.CancelChanges();
return true;
}
|
AcceptChanges |
Description Perform AcceptChanges to any row modification Parameters - Remarks Return Value
Samples
function CustomFunction()
{ var grid = ISGetObject("WebGrid1"); var wgRow = grid.GetSelectedObject().GetRowElement(); wgRow.AcceptChanges();
return true;
}
|
BeginEdit |
Description Perform EditMode Parameters - Remarks Return Value
Samples
function CustomFunction()
{ var grid = ISGetObject("WebGrid1"); var wgRow = grid.GetSelectedObject().GetRowElement();
wgRow.BeginEdit();
return true;
}
|
SetForceNoEdit |
Description Sets the current row as editable. Parameters
Remarks
Samples
function DoRowSelect(controlId, tblName, rowIndex, rowEl)
{ var grid = ISGetObject(controlId); var row = grid.RootTable.ToRowObject(rowEl); if (row.Type == "NewRow") { var cells = row.GetCells(); cells.GetNamedItem("CustomerID").SetForceNoEdit(newRowNoEdit); } } |
Check |
Description Sets the current row as checked. Parameters - Remarks Return Value
Samples
function CheckRows()
{ // obtain grid's object var grid = ISGetObject("WebGrid1");
// obtain WebGridRow object of 11th row
var row = grid.RootTable.GetRow(10); for (var i=0; i<5; i++) { // set the row as checked row.Check();
// obtain the previous WebGridRow object
row = row.GetPreviousRow(); } } |
Uncheck |
Description Sets the current row as unchecked. Parameters - Remarks Return Value
Samples
function UnCheckRows()
{ var grid = ISGetObject("WebGrid1"); var row = grid.RootTable.GetRow(3); for (var i=0; i<4; i++) { row.Uncheck(); row = row.GetNextRow(); } } |
IsSelected |
Description Determines whether the current row is selected. Parameters - Remarks Return Value
Samples
function DoClick()
{ var grid = ISGetObject("WebGrid1"); if (grid.GetSelectedObject() == null) { alert("Please select a row."); return; } var row = grid.GetSelectedObject().GetRowObject();
alert(row.IsSelected());
var firstRow = grid.RootTable.GetRow(0);
alert(firstRow.IsSelected());
return true;
} |
GetElement |
Description Gets the HTML element from current row. Parameters - Remarks Return Value
Samples
function ObtainRow()
{ var grid = ISGetObject("WebGrid1"); if (grid.GetSelectedObject() == null) { alert("Please select a row."); return; } var row = grid.GetSelectedObject().GetRowObject();
// WG4 standardized on the keyword GetElement
// on every objects in order to get the html element. var rowElement = row.GetElement(); rowElement.style.height = "30px"; alert("Current selected row's Height is now 30px"); } |
GetCells |
Description Gets the whole WebGridCell collection of the current row. Parameters - Remarks Return Value Samples
function GetCellText()
{ var grid = ISGetObject("WebGrid1");
// get selected object
var curSelObj = grid.GetSelectedObject(); if (curSelObj == null) { alert("No row selected. Please select a row"); } else { // get the WebGridRow object var row = curSelObj.GetRowObject(); if (row.Type == "GroupHeader") { alert("Currently selected row is a Group Row. There is no cell information."); } else if (row.Type == "Record") { // obtain WebGridCellCollection of the specified row. var cells = row.GetCells();
// get the address' WebGridCell object by name.
var addressCell = cells.GetNamedItem("Address"); alert("Current selected row's Address cell has this text : " + addressCell.Text + " The cell's value is : " + (addressCell.Value == null ? "No Value" : addressCell.Value)); } } } |
GetCell |
Description Gets the WebGridCell object from a row. Parameters - Remarks Return Value
Samples
function ObtainCell()
{ var grid = ISGetObject("WebGrid1");
if (grid.GetSelectedObject() == null)
{ alert("Please select a row."); return; } var row = grid.GetSelectedObject().GetRowObject(); if (row.Type == "Record") { var cell = row.GetCell("CompanyName");
// WG 4 standarized on the keyword GetElement
//on every objects in order to get the html element. var cellElement = cell.GetElement(); cellElement.style.color = "green"; alert("The CompanyName cell of current selected row's ForeColor is now Green."); } else alert("Please select a Record Row"); } |
ExpandGroupRow |
Description Expands group rows of this row. Parameters - Remarks Return Value
function ExpandGroupRow()
{ var grid = ISGetObject("WebGrid1");
// get the WebGridRow object instead of element.
var currentRow = grid.GetSelectedObject().GetRowObject();
// expand group row
currentRow.ExpandGroupRow(); btnExpandGR.disabled = true; btnCollapseGR.disabled = false; } |
CollapseGroupRow |
Description Collapses group rows of this row. Parameters - Remarks Return Value
Samples
function CollapseGroupRow()
{ var grid = ISGetObject("WebGrid1");
// get the WebGridRow object instead of element.
var currentRow = grid.GetSelectedObject().GetRowObject();
// collapse group row
currentRow.CollapseGroupRow();
btnExpandGR.disabled = false;
btnCollapseGR.disabled = true; } |
ExpandChildRow |
Description Expands child rows of this row. Parameters - Remarks Return Value Samples
function ExpandChild()
{ var grid = ISGetObject("WebGrid1"); var selObj = grid.GetSelectedObject(); if (selObj == null) { alert("Please select a row"); return; } else { var row = selObj.GetRowObject();
// demonstrate server-side alike object model hierarchy
if (row.Table.ChildTables.length > 0) { if (!row.ChildExpanded) row.ExpandChildRow(); else alert("Row already expanded!"); } else alert("This row doesn't have any child rows!"); } } |
CollapseChildRow |
Description Collapses child rows of type Self Reference of this row. Parameters - Remarks Return Value Samples
function CollapseChild()
{ var grid = ISGetObject("WebGrid1"); var selObj = grid.GetSelectedObject(); if (selObj == null) { alert("Please select a row"); return; } else { var row = selObj.GetRowObject();
// demonstrate server-side alike object model hierarchy
if (row.Table.ChildTables.length > 0) { if (row.ChildExpanded) row.CollapseChildRow(); else alert("Row already collapsed!"); } else alert("This row doesn't have any child rows!"); } } |
ExpandSelfRefRow |
Description Expands child rows of type Self Reference of this row. Parameters - Remarks Return Value Samples
function ExpandSelfRefRow()
{ // obtain grid's object var grid = ISGetObject("WebGrid1");
// select the first row
var row = grid.RootTable.GetRow(0); // only expand the first row if : // 1) It's a SelfReference row type // 2) It hasn't been expanded yet if (row.IsSelfRefRow && !SelfRefExpanded) { row.ExpandSelfRefRow(); } return true;
}
|
CollapseSelfRefRow |
Description Collapses child rows of type Self Reference of this row. Parameters - Remarks - Return Value
Samples
function CustomFunction()
{ // obtain grid's object var grid = ISGetObject("WebGrid1"); // select the first row var row = grid.RootTable.GetRow(0); // only expand the first row if : // 1) It's a SelfReference row type // 2) It has been expanded if (row.IsSelfRefRow && SelfRefExpanded) { row.CollapseSelfRefRow(); } return true; } |
Select |
Description Selects a row. Parameters - Remarks - Return Value
Samples
function SelectNewRow()
{ var grid = ISGetObject("WebGrid1");
// return the html element of the newrow
var newRowElement = grid.RootTable.GetNewRow();
// convert to WebGridRow object
var newRow = grid.RootTable.ToRowObject(newRowElement); // select new row newRow.Select(); // populate cells var cells = newRow.GetCells();
// activate edit cell on City cell,
// instead of first cell cells.GetNamedItem("City").ActivateEdit();
// set the CustomerID cell's text to NEWCUST,
// 2nd parameter is true indicating that the value is same as the text.
cells.GetNamedItem("CustomerID").SetText("NEWCUST", true);
cells.GetNamedItem("Address").SetText("New Address", true); // indicates that this row's data has been changed. newRow.SetDataChanged();
// sets the row's status as edited,
// as if user has typed inside the cell. grid.MarkEdit(); } |
GetChildRow |
Description Gets the child row object based on defined relations. Parameters - Remarks - Return Value
Samples
function ExpandAndGetChild()
{ var grid = ISGetObject("WebGrid1"); var selObj = grid.GetSelectedObject();
if (selObj == null)
{ alert("Please select a row"); return; } else { var row = selObj.GetRowObject(); // demonstrate server-side alike // object model hierarchy if (row.Table.ChildTables.length > 0) { if (!row.ChildExpanded) { // 1st parameter indicates using synchronous mode row.ExpandChildRow(true); // the advantage of sync mode is the ability // to get child rows in same code flow
// get the Orders child rows collection
// belong to this customer var childRows = row.GetChildRow("Orders"); var s = ""; for (var i=0; i<childRows.length; i++) s += " OrderID: " + childRows[i].KeyValue; alert("Customer '" + row.KeyValue + "' has " + childRows.length + " orders. The orders are:" + s); } else alert("Row already expanded!"); } else alert("This row doesn't have any child rows!"); } } |
GetParentRow |
Description Gets the parent row based on defined relations. Parameters - Remarks - Return Value
Samples
function GetParentRow()
{ var grid = ISGetObject("WebGrid1"); var selObj = grid.GetSelectedObject();
if (selObj == null)
{ alert("Please select a row"); return; } else { var row = selObj.GetRowObject(); if (row.Table.IsRootTable) alert("Please select a child row"); else { // get the parent row of this child var parentRow = row.GetParentRow(); alert("The parent row of this order is: " + parentRow.KeyValue); if (confirm("Do you want to select the parent row?")) { // select the parent row parentRow.Select(); } } } } |
GetGroupChildRows |
Description Gets the GroupChildRow collection of the current row. Parameters - Remarks Return Value
Samples
function GetGroupRowChilds()
{ var grid = ISGetObject("WebGrid1");
// get the WebGridRow object
// instead of element. var currentRow = grid.GetSelectedObject().GetRowObject();
// get group child rows of
// current row object. var groupChildRows = currentRow.GetGroupChildRows(); var s = "Current selected group row is '" + currentRow.GroupRowText + "'. The child rows contained by this group are: "; for (var i=0; i<groupChildRows.length; i++) { var row = groupChildRows[i]; s += "Row " + i + ", Type=" + row.Type + ", KeyValue=" + row.KeyValue + " "; } alert(s); } |
GetChanges |
Description Returns the changes made to this row Parameters rowState Specifies the state of the changes to get. Remarks Return Value
Samples |
GetRowState |
Description Returns the state of this row. It will returns Unmodified if this row has no changes. Parameters - Remarks Return Value
Samples |
InvalidateRowState |
Description Invalidate the state of this row to be processed in the next synchronization. Parameters - Remarks Return Value
Samples |
UndoChanges |
Description Undo changes made to this row Parameters skipUpdateStatus Specifies whether to skip the status updating after undo. Remarks Return Value
Samples |
AddPendingChanges |
Description Mark changes made to this row and add it into pending changes collection. Parameters - Remarks Return Value
Samples |
UpdatePendingChangesUI |
Description Synchronize the pending changes data with Grid's user interface elements. Parameters isProgrammatic Specifies whether the method is called by user code. Remarks Return Value
Samples |
SetDeleted |
Description Mark this row as deleted. Parameters - Remarks Return Value
Samples |
GetGroupRowLevel |
Description Gets the group row level of this row. Parameters - Remarks Return Value
Samples |
HasCollapsedParent |
Description Whether this row has collapsed parents. Parameters - Remarks Return Value
Samples |
HasGroupedChilds |
Description Whether this row has grouped child rows. Parameters - Remarks Return Value
Samples |
HasExpandedChilds |
Description Whether this row has expanded child rows. Parameters - Remarks Return Value
Samples |
ExpandGroupRowsToThisRow |
Description Expand all parent group rows down to this row. Parameters - Remarks Return Value
Samples |
CopyTo |
Description Copies this row's structure and data to destination object. Parameters targetObject isModifiedOnly followTargetStructure Remarks Return Value
Samples |