ASPxClientGridViewBatchEditApi.SetCellValue(visibleIndex, columnFieldNameOrId, value) Method
Sets the value of the specified cell.
Declaration
SetCellValue(
visibleIndex: number,
columnFieldNameOrId: string,
value: any,
displayText?: string,
cancelCellHighlighting?: boolean
): void
Parameters
Name | Type | Description |
---|---|---|
visibleIndex | number | An integer zero-based index that identifies the row containing the processed cell. |
columnFieldNameOrId | string | A string value that specifies the field name or unique identifier (the column’s WebColumnBase.Name property value) of a column containing the processed cell. |
value | any | An object that contains the new cell value. |
displayText | string | A string value that specifies the cell display text. |
cancelCellHighlighting | boolean | true to cancel highlighting of the modified cell, false to highlight the modified cell. |
Remarks
Use the SetCellValue property to change the value of the specified cell when the latter is not in edit mode.
Note
The SetCellValue method is not in effect in the following situations:
- If the column’s GridColumnEditFormSettings.Visible property is set to false.
If the cell is in edit mode. It is necessary to use the ASPxClientGridView.BatchEditEndEditing event handler to change the cell value:
function onBatchEditEndEditing(s,e) { e.rowValues[columnIndex].value = newValue; e.rowValues[columnIndex].text = displayText; }
Examples
- ASPxClientGridViewBatchEditApi.SetCellValue(Int32, String, Object)
function OnHeaderCheckBoxCheckedChanged(s, e) {
var visibleIndices = Grid.batchEditApi.GetRowVisibleIndices();
var totalRowsCountOnPage = visibleIndices.length;
for (var i = 0; i < totalRowsCountOnPage ; i++) {
Grid.batchEditApi.SetCellValue(visibleIndices[i], "Discontinued", s.GetChecked())
}
}
- ASPxClientGridViewBatchEditApi.SetCellValue(Int32, String, Object, String, Boolean)
function OnBatchEditEndEditing(s, e) {
window.setTimeout(function () {
var price = s.batchEditApi.GetCellValue(e.visibleIndex, "Price");
var quantity = s.batchEditApi.GetCellValue(e.visibleIndex, "Quantity");
s.batchEditApi.SetCellValue(e.visibleIndex, "Sum", price * quantity, null, true);
}, 10);
}
Online Examples
WebForms:
ASPxGridView - Batch Edit - How to calculate values on the fly
ASPxGridView - How to implement a popup Edit Form for GridView in Batch Edit mode
ASPxGridView - Batch Edit - How to change a cell value based on another cell value
MVC: