This example demonstrates how to change a column value (Price) when another column (Percentage) is changed and vice versa.
The ASPxClientGridView class implements the batchEditApi property that exposes an API to work with the grid in batch mode on the client side.
After a user edits the value, the BatchEditEndEditing event is raised. In the event handler, you can get a cell value in the following ways:
- The batchEditApi.GetCellValue method returns the value of the specified cell that is not in edit mode.
- The rowValues property returns the new value of the specified cell that is in edit mode.
The batchEditApi.SetCellValue method allows you to specify a cell value.
function OnBatchEditEndEditing(s, e) {
var cPrice = s.GetColumnByField("Price");
var cPercentage = s.GetColumnByField("Percentage");
var cost = s.batchEditApi.GetCellValue(e.visibleIndex, "Cost");
if (fieldName == "Price") {
var price = e.rowValues[cPrice.index].value;
s.batchEditApi.SetCellValue(e.visibleIndex, "Percentage", (price - cost) / (cost), null, true);
}
if (fieldName == "Percentage") {
var percentage = e.rowValues[cPercentage.index].value;
s.batchEditApi.SetCellValue(e.visibleIndex, "Price", cost + (cost * percentage), null, true);
}
}
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
(you will be redirected to DevExpress.com to submit your response)