ASPxClientGridViewBatchEditApi.SetCellValue(visibleIndex, columnFieldNameOrId, value) Method
Assigns a new value to the specified cell in batch edit mode.
Declaration
SetCellValue(
visibleIndex: number,
columnFieldNameOrId: string,
value: any,
displayText?: string,
cancelCellHighlighting?: boolean
): void
Parameters
Name | Type | Description |
---|---|---|
visibleIndex | number | The visible index of the row that contains the processed cell. |
columnFieldNameOrId | string | The field name or unique identifier (the Name property value) of the column that contains the processed cell. |
value | any | The new cell value. |
displayText | string | The cell display text. |
cancelCellHighlighting | boolean |
|
Remarks
Call the SetCellValue
method to assign a new value to the cell specified by the row’s visible index.
// Sets a new value to the specified cell
clientGrid.batchEditApi.SetCellValue(rowIndex, 'ContactName', 'New customer');
// Sets a new value to the specified cell and disables its highlighting
clientGrid.batchEditApi.SetCellValue(rowIndex, 'ContactName', 'New customer', null, false)
This method is not in effect in the following cases:
- The column’s Visible property is set to
false
. - The specified cell is in edit mode.
Add a New Row and Specify Its Cell Values
When you call the AddNewRow method to create a new row, the grid switches to edit mode. The code sample below gets the visible index of the inserted row (the rowVisibleIndex property) and ends cell editing (the EndEdit method) to allow the grid to assign new values to the cells within the inserted row.
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" KeyFieldName="CustomerID"
ClientInstanceName="clientGrid">
<Columns>
<dx:GridViewDataTextColumn FieldName="ContactName" />
<%--...--%>
</Columns>
<SettingsEditing Mode="Batch" />
</dx:ASPxGridView>
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Add New Row" AutoPostBack="false">
<ClientSideEvents Click="OnButtonClick" />
</dx:ASPxButton>
function OnButtonClick(s, e) {
clientGrid.batchEditApi.AddNewRow();
var rowIndex = clientGrid.batchEditApi.GetEditCellInfo().rowVisibleIndex;
clientGrid.batchEditApi.EndEdit();
clientGrid.batchEditApi.SetCellValue(rowIndex, 'ContactName', 'New customer');
}