Intersoft WebGrid Documentation
WebGridRow
Send comments on this topic.
Intersoft WebGrid > Client-side References > WebGridRow

Glossary Item Box

 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

object (WebGridRow)

Samples

In this sample, GetNextRow() method is utilized in order to obtain the next WebGridRow object. This sample can be seen in WG40Tutorials -> Programmatic_UI2.aspx.

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

object (WebGridRow)

Samples

In this sample, GetPreviousRow() method is utilized in order to obtain the previous WebGridRow object. This sample can be seen in WG40Tutorials -> Programmatic_UI2.aspx.

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
useSync ( boolean )
Indicates whether asynchronous mode is utilized.

Remarks
-

Return Value

void
Samples
Perform row update

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
useSync ( boolean )
Indicates whether asynchronous mode is utilized.

Remarks
-

Return Value
void
Samples
Perform delete row

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
-

Return Value
void
Samples
Manually invoke OnRowValidate client side function

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
-

Return Value
boolean

Samples

Check whether the NewRow is dirty or not

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
-

Return Value
void
Samples
Use SetDataChanged method

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

boolean

Samples

Determine the value of IsMarkedEdit property

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

void

Samples

Perform CancelChanges

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

void

Samples

Perform AcceptChanges

function CustomFunction()
{
  var grid = ISGetObject("WebGrid1");
  var wgRow = grid.GetSelectedObject().GetRowElement();  

  wgRow.AcceptChanges();
  return true;
}  
BeginEdit Description
Perform EditMode

Parameters
-

Remarks
-

Return Value

void

Samples

Perform edit

function CustomFunction()
{
  var grid = ISGetObject("WebGrid1");
  var wgRow = grid.GetSelectedObject().GetRowElement();  
  wgRow.BeginEdit();  
  return true;
SetForceNoEdit Description
Sets the current row as editable.

Parameters
v ( boolean )
true means Not Editable, false means EditAble

Remarks

The parameter decides whether the current row is editable.
Return Value
void

Samples

Configure the row as not editable

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

void

Samples

Check the current row sample

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

void

Samples

Uncheck the current row sample.

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

boolean

Samples

Determines whether the current row is selected.
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

object (HTML element)

Samples

Obtain the raw HTML element from current WebGridRow object.

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
object (WebGridCell collection)

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

object (WebGridCell)

Samples

Obtain a WebGridCell object by using GetCell method

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

void
Samples
Expand group row

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

void

Samples

Collapse group row

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
void

Samples

Expand child row by using ExpandChildRow method

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
void

Samples

Collapse child rows by using CollapseChildRow method.

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
void

Samples

Expand a self reference row type.

 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

void

Samples

Collapse SelfRef row

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

void

Samples

Select a row

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

object (WebGridRow)

Samples

Gets the child row object based on defined relations.

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

object (WebGridRow)

Samples

Obtains the parent's WebGridRow object of current child WebGridRow object.

 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

object (GroupChildRow)

Samples

In this sample, the group child rows of the current row object can be obtained further. This sample can be seen in Programmatic_UI.aspx sample.

 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

object (WebGridRowChanges)

Samples

GetRowState Description
Returns the state of this row. It will returns Unmodified if this row has no changes.

Parameters
-

Remarks
-

Return Value

void

Samples

InvalidateRowState Description
Invalidate the state of this row to be processed in the next synchronization.

Parameters
-

Remarks
-

Return Value

void

Samples

UndoChanges Description
Undo changes made to this row

Parameters
skipUpdateStatus
Specifies whether to skip the status updating after undo.


Remarks
-

Return Value

void

Samples

AddPendingChanges Description
Mark changes made to this row and add it into pending changes collection.

Parameters
-

Remarks
-

Return Value

void

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

void

Samples

SetDeleted Description
Mark this row as deleted.

Parameters
-

Remarks
-

Return Value

void

Samples

GetGroupRowLevel Description
Gets the group row level of this row.

Parameters
-

Remarks
-

Return Value

void

Samples

HasCollapsedParent Description
Whether this row has collapsed parents.

Parameters
-

Remarks
-

Return Value

boolean

Samples

HasGroupedChilds Description
Whether this row has grouped child rows.

Parameters
-

Remarks
-

Return Value

boolean

Samples

HasExpandedChilds Description
Whether this row has expanded child rows.

Parameters
-

Remarks
-

Return Value

boolean

Samples

ExpandGroupRowsToThisRow Description
Expand all parent group rows down to this row.

Parameters
-

Remarks
-

Return Value

void

Samples

CopyTo Description
Copies this row's structure and data to destination object.

Parameters
targetObject

isModifiedOnly

followTargetStructure

Remarks
-

Return Value

void

Samples

©2012 Intersoft Solutions Corp. All Rights Reserved.