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

Glossary Item Box

 WebGridCell Properties

Position Description
Gets the position of the cell from its collection.

ValueType
integer

Default Value
-
Text Description
Gets or sets the text that will be displayed in cell.

ValueType
string

Default Value
-
Tag Description
Gets the custom data for the cell object.

ValueType
string

Default Value
""
Value Description
Gets the cell's value.

ValueType
object

Default Value
-
Column Description
Gets the column object to which this cell belongs.

ValueType
object (WebGridColumn)

Default Value
-
DataChanged Description
Returns whether cell's data has been changed.

ValueType
boolean

Default Value
false
ForceNoEdit Description
Determines whether this cell will be forced not to allow editing.

ValueType
boolean

Default Value
false
Name Description
The name of the item in its collection.

ValueType
string

Default Value
-
CellElement Description
Gets the HTML element of this cell object.

ValueType
object (HTML element)

Default Value
-
Row Description
Returns the row object to which this cell belongs.

ValueType
object (WebGridRow)

Default Value
-
Table Description
Returns the table object to which this cell belongs.

ValueType
object (WebGridTable)

Default Value
-
Grid Description
Returns the grid object to which this cell belongs.

ValueType
object (WebGrid)

Default Value
-
Modified Description
Represents whether this cell has been modified (dirty).

ValueType
boolean

Default Value
false
OldValue Description
Represents the cell value before the cell is modified.

ValueType
object

Default Value
""
OldText Description
Represents the cell text before the cell is modified.

ValueType
string

Default Value
""
ContentMode Description
Indicates whether to treat the cell text as HTML content or plain text.

ValueType
string

Default Value
"Text"
Value Description
Represents the value of the cell.

ValueType
object

Default Value
-

 WebGridCell Methods

GetElement Description
Gets the HTML element of this cell.

Parameters
-

 

Remarks
-

Return Value

object (HTML element)

Samples

This functions sets the color of of a "CompanyName" cell from the selected row to green.

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");
         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");

IsForeignColumn Description
Returns true if the cell is in a foreign key column. This method is available only for the cell in a child table, meaning that the grid must be in Hierarchical mode.

Parameters
x ( string )
The XML string that contains the constraints of the childtable.

Remarks
-

Return Value

boolean

Samples

This function alerts the is-foreign-column status of a child table cell.

function IsForeignCell()
{
    var grid = ISGetObject("WebGrid1");
    if (grid.GetSelectedObject() == null)
    {
        alert("Please select a child row.");
        return;
    }
    var row = grid.GetSelectedObject().GetRowObject();
    if (row.Type == "Record" && row.SubTable != null)
    {
        var cell = row.GetCell("CustomerID");
        var strXml = cell.SubTable.GetConstraintXml();
        alert("The cell is in a foreign column: " + cell.IsForeignColumn(strXml));
    }
    else
        alert("Please select a child row.");
}
IsActive Description
Returns a value that indicates whether the cell is in active edit mode.

Parameters
-

 

Remarks
-

Return Value

boolean

Samples

This function alerts the active status of a "CompanyName" cell of a selected row.

function IsCellActive()
{
    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");
        alert( cell.IsActive());
    }
    else
        alert("Please select a Record Row");
}
GetParentKeyValue Description
Gets the key value of the cell's parent row. This method is available only for the cell in a child table, meaning that the grid must be in Hierarchical mode.

Parameters
x ( string )
The XML string that contains the constraints of the childtable.

Remarks
-

Return Value

string

Samples

This function alerts the cell's parent key value.

function ParentKeyValue()
{
    var grid = ISGetObject("WebGrid1");
    if (grid.GetSelectedObject() == null)
    {
        alert("Please select a child row.");
        return;
    }
    var row = grid.GetSelectedObject().GetRowObject();
    if (row.Type == "Record" && row.SubTable != null)
    {
        var cell = row.GetCell("CustomerID");
        var strXml = cell.SubTable.GetConstraintXml();
        alert("The cell's parent key value: " + cell.GetParentKeyValue(strXml));
    }
    else
        alert("Please select a child row.");
}
SetText Description
Sets the text of this cell.

Parameters
s ( string )
The new text to be set.
sameValue ( boolean )
Determines whether the value of the cell should be the same as the new text.

Remarks

-

Return Value

void

Samples

This function changes the text of a cell from a selected row.

function SetText()
{
    var grid = ISGetObject("WebGrid1");
    
    if (grid.GetSelectedObject() == null)
            alert("Please select a row."); return;
    
    var row = grid.GetSelectedObject().GetRowObject();
    var cell = row.GetCell("ProductName");
    
    if (row.Type == "Record")
         cell.SetText('Test', true);
    else
        alert("Please select a Record Row");
}
SetValue Description
Sets the value of this cell.

Parameters
v ( Depends on the cell type. )
The value to be set. No particular type required because we can assign a string, number or boolean value to the parameter.

Remarks

-

Return Value

void

Samples

This function changes the value of a cell from a selected row.

function SetValue()
{
    var grid = ISGetObject("WebGrid1");
    
    if (grid.GetSelectedObject() == null)
            alert("Please select a row."); return;
    
    var row = grid.GetSelectedObject().GetRowObject();
    var cell = row.GetCell("ProductName");
    
    if (row.Type == "Record")
         cell.SetValue('Test');
    else
        alert("Please select a Record Row");
}
SetForceNoEdit Description
Forces this cell not to allow editing.

Parameters
v ( boolean )
If v is null or not specified then the default is true. If this is set to false, the cell would be editable.

Remarks

-

Return Value

void

Samples

This function sets a cell from the selected row not to allow editing.

function SetNoEdit()
{
    var grid = ISGetObject("WebGrid1");
    
    if (grid.GetSelectedObject() == null)
            alert("Please select a row."); return;
    
    var row = grid.GetSelectedObject().GetRowObject();
    var cell = row.GetCell("ProductName");
    
    if (row.Type == "Record")
         cell.SetForceNoEdit(true);
    else
        alert("Please select a Record Row");
}
Select Description
Selects this cell.

Parameters  

-

Remarks

-

Return Value

void

Samples

This function selects a "CompanyName" cell of a selected row.

function SelectCell()
{
    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");
        cell.Select();
    }
    else
        alert("Please select a Record Row");
}
SetChanges Description
Change the text and value of this cell.

Parameters  
text
The new text to be set.

value
The new value to be set. This parameter is optional, and only useful for valuelist column.

Remarks

-

Return Value

void

Samples

This function selects a "CompanyName" cell of a selected row.

function SelectCell()
{
    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");
        cell.Select();
    }
    else
        alert("Please select a Record Row");
}
©2012 Intersoft Solutions Corp. All Rights Reserved.