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

Glossary Item Box

 WebGrid Edit Global Functions

wgGetFirstEditableCell Description
Gets the first editable cell index of the specified row.

Parameters
row ( object - row element )
The row element

Return Value

integer

Samples

This sample shows how to get the first editable cell index in the specified row.

function doRowSelect(controlId, tblName, rowIndex, rowEl)
{
    //gets the first editable cell
    var firstCellIndex = wgGetFirstEditableCell(rowEl);
    return true;
}
wgGetNextEditableRow Description
Gets the next editable row from specified row.

Parameters
hTbl ( object - table element )
The table element
row ( object - row element )
The row element

Return Value

object (row element)

Samples
This sample shows how to get the next editable row from the current row selected.
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{
    //gets the grid object
    var grid = ISGetObject(controlId);
 
    //gets the table element
    var tbl = grid.Tables[tblName].GetElement(WG40.BODY,WG40.HTMLTABLE);

    //gets the next editable row
    wgGetNextEditableRow(tbl,rowEl);

    return true;
}
wgGetPrevEditableRow Description
Gets the previous editable row from specified row.

Parameters
hTbl ( object - table element )
The table element
row ( object - row element )
The row element

Return Value

object (row element)

Samples
This sample shows how to get the previous editable row from the current row selected.
function doRowSelect(controlId, tblName, rowIndex, rowEl)
{
    //gets the grid object
    var grid = ISGetObject(controlId); 
    

    //gets the table element
    var tbl = grid.Tables[tblName].GetElement(WG40.BODY,WG40.HTMLTABLE); 
    

    //gets the previous editable row
    wgGetPrevEditableRow(tbl,rowEl);
    return true;
}

wgGetNextEditableCell Description
Gets the next editable cell based on a given cell element or row element.

Parameters
cell ( object - cell element )
The cell element
_row ( object - row element )
The row element (optional)

Return Value

object (cell element)

Samples
This sample shows how to get the next editable cell from the current cell selected.
function doEnterEditMode(gridId,tblName,editObject)
{
    //get the grid object
    var grid = ISGetObject(gridId);

    //get the current row object
    var row = grid.GetSelectedObject().GetRowObject();

    //get the current cell element
    var cell = row.GetCells().GetNamedItem("City").GetElement(WG40.BODY,WG40.HTMLCELL);

    //get the next editable cell
    var nextCell = wgGetNextEditableCell(cell);

    return true;
}
wgGetPrevEditableCell Description
Gets the previous editable cell based on a given cell element or row element.

Parameters
cell ( object - cell element )
The cell element
_row ( object - row element )
The row element (optional)

Return Value

object (cell element)

Samples
This sample shows how to get the previous editable cell from the current cell selected.
function doEnterEditMode(gridId,tblName,editObject)
{
    //get the grid object
    var grid = ISGetObject(gridId);

    //get the current row object
    var row = grid.GetSelectedObject().GetRowObject()

    //get the current cell element
    var cell = row.GetCells().GetNamedItem("City").GetElement(WG40.BODY,WG40.HTMLCELL);

    //get the previous editable cell
    var prevCell = wgGetPrevEditableCell(cell);

    return true;
}
wgGetLastEditableCell Description
Gets the last editable cell of the specified row element.

Parameters
row ( object - row element )
The row element

Return Value

object (cell element)

Samples
This sample shows how to get the last editable cell from the current cell selected.
function doEnterEditMode(gridId,tblName,editObject)
{
    //get the grid object
    var grid = ISGetObject(gridId);

    //get the current row object
    var rowEl = grid.GetSelectedObject().GetRowObject().
GetElement(WG40.BODY,WG40.HTMLROW);

    //get the last editable cell
    var lastCell = wgGetLastEditableCell(rowEl);

    return true;
}
wgActiveCellValid Description
Determines whether the specified row element is currently an active cell row.

Parameters
grid ( object - WebGrid )
The grid object
row ( object - row element )
The row element

Return Value

boolean

Samples
This sample shows how to determine whether or not the selected row is an active cell row.

function doEnterEditMode(gridId,tblName,editObject)
{
    //get the grid object
    var grid = ISGetObject(gridId);

    //get the row element of the selected row
    var rowEl = grid.GetSelectedObject().GetRowObject().GetElement();

    //determines whether or not the selected row is an active cell row
    var flag = wgActiveCellValid(grid,rowEl); //will return true if in edit mode

    return true;
}
wgIsRowEditable Description
Determines whether or not the specified row is editable.

Parameters
row ( object - row element )
The row element

Return Value

boolean

Samples
This sample shows how to determine whether or not the selected row is editable.

function doRowSelect(gridId, tblName, rowIndex, rowEl)
{
    var flag = wgIsRowEditable(rowEl);
    return true;
}
wgGetUnMask Description
Unmask a value of a specified cell.

Parameters
grid ( object - WebGrid )
The grid object
col ( object - WebGridColumn )
The column object
el ( object - cell element )
The cell element
returnText ( boolean )
The flag that determines whether or not the return type of unmasked value is text
text ( string )
The value that will be unmasked

Return Value

void

Samples
This sample shows how to unmask the value of a specified cell.

function doEnterEditMode(gridId,tblName,editObject)
{
    //get the grid object
    var grid = ISGetObject(gridId);

    //get the table object
    var oTbl = grid.RootTable;

    //get the cell element
    var cell = oTbl.GetRow(0).GetCells().GetNamedItem("ShipAddress").GetElement();
    var col = grid.GetColumnByElement(cell);

    //unmask the cell's value
     wgGetUnMask(grid,col,cell,true,cell.innerText);

    return true;
}
wgGetMask Description
Masks a value of a specified cell.

Parameters
grid ( object - WebGrid )
The grid object
editObj ( object - EditObject )
The edit object
value ( string )
The value that will be masked
_table ( object - table element )
The table element (optional)
_cell ( object - cell element )
The cell element (optional)

Return Value

void

Samples
This sample shows how to mask the value of the specified cell.

function doEnterEditMode(gridId,tblName,editObject)
{
    //get the grid object
    var grid = ISGetObject(gridId);

    //get the table object
    var oTbl = grid.RootTable;

    //get the table element
    var eTbl = oTbl.GetElement(WG40.BODY,WG40.HTMLTABLE);

    //get the cell element
    var cell = oTbl.GetRow(0).GetCells().GetNamedItem("ShipAddress").GetElement();

    //mask the cell's value
     wgGetMask(grid,editObject,cell.innerText,eTbl,cell);

    return true;
}
wgDispObjGeneric Description
Displays generic edit object according to grid's active cell and specified parameters.

Parameters
grid ( object - grid element )
The grid element.
edit ( object - EditObject element )
The edit control html element.
el ( object - cell element )
The cell element to which the edit control is attached.
adjLeft ( integer )
The left adjustment to the cell position relatively.
adjTop ( integer )
The top adjustment to the cell position relatively.
ignoreSize ( boolean )
The flag that determines whether or not to ignore the size calculation of edit control.
editType ( string )
The edit type.
calDD ( boolean )
The flag that determines whether or not the edit object is a DropDownList object.

Return Value

void

Samples
This sample shows how to display the edit object of a specified cell.

function doEnterEditMode(gridId, tblName, editObject)
{
    //get the grid object
    var grid = ISGetObject(gridId);

    //get the table object
    var oTbl = grid.RootTable;

    //get the cell element
    var cell = oTbl.GetRow(0).GetCells().GetNamedItem("ShipAddress").GetElement();

    //display the edit object at the specified cell
    wgDispObjGeneric(grid, editObject.element, cell, 1, 1, null, null, false);

    return true;
}
wgIsRowMarkedEdit Description
Determines whether or not the specified row has been marked as edited.

Parameters
row ( object - row element )
The row element

Return Value

boolean

Samples
This sample shows how to determine whether or not the selected row is marked edit.

function doEditKeyDown(gridId, tblName, editObject)

    //get the grid object
    var grid = ISGetObject(gridId); 

    //get the row element of the first row
    var rowEl = grid.RootTable.GetRow(0).GetElement(WG40.BODY,WG40.HTMLROW); 

    //if the row element is dirty      
    if(wgIsRowMarkedEdit(rowEl)
        alert("Row 1 is marked edit");

    return true;
}
wgIsRowDirty Description
Determines whether or not the specified row is dirty (one of its cells' content has been modified).

Parameters
row ( object - row element )
The row element

Return Value

boolean

Samples
This sample shows how to determine whether or not the selected row is dirty.

function doEditKeyDown(gridId, tblName, editObject)

    //get the grid object
    var grid = ISGetObject(gridId); 

    //get the row element of the first row
    var rowEl = grid.RootTable.GetRow(0).GetElement(WG40.BODY,WG40.HTMLROW); 

    //if the row element is dirty      
    if(wgIsRowDirty(rowEl)
        alert("Row 1 is dirty");

    return true;
}
wgHighlightEditCell Description
Highlights specified cell as current active edit cell.

Parameters
cell ( object - cell element )
The cell element
mode ( string )
For internal use only - not intended to be used directly by developers.
newcell ( string )
For internal use only - not intended to be used directly by developers.

Return Value

void

Samples
This sample shows how to highlight the first cell of the first row on a button click event.

function doButtonClick()
{
    //get the grid object 
    var grid = ISGetObject("WebGrid1"); 

    //get the table object
    var table = grid.RootTable;

    //get the first row object
    var row = table.GetRow(0); 

    //get the first cell element
    var cell = row.GetCell(0).GetElement();

    //highlight the cell     
    wgHighlightEditCell(cell);

    return true;
}
©2012 Intersoft Solutions Corp. All Rights Reserved.