@ AuthorYHC in this tutorial, you will learn how to include an operation column in an editable datagrid. An operation column usually contains some operation values from one or more other columns. view the Demo. First, create an editable datagrid. This is some of the Editable columns we have created, & amp; #39; list... syntaxHighligh
@ Author YHC
In this tutorial, you will learn how to include an operation column in an editable datagrid. An operation column usually contains some operation values from one or more other columns.
View Demo
First, create an editable datagrid, which is some of the Editable columns we have created. The 'listprice', 'amount', and 'unitcost' columns are defined as the numberbox editing type, the operation column is the 'unitcost' field,
Returns the result of multiplying listprice by the amount column.
[Html]
Title = "Editable DataGrid with Calculated Column" iconCls = "icon-edit" singleSelect = "true"
IdField = "itemid" url = "data/datagrid_data.json">
Item ID
List Price
Amount
Unit Cost
Attribute
Status
Title = "Editable DataGrid with Calculated Column" iconCls = "icon-edit" singleSelect = "true"
IdField = "itemid" url = "data/datagrid_data.json">
Item ID
List Price
Amount
Unit Cost
Attribute
Status
When a user clicks a row, we start an editing action.
[Javascript]
Var lastIndex;
$ ('# Tt'). datagrid ({
OnClickRow: function (rowIndex ){
If (lastIndex! = RowIndex ){
$ ('# Tt'). datagrid ('enabled', lastIndex );
$ ('# Tt'). datagrid ('ineinedit', rowIndex );
SetEditing (rowIndex );
}
LastIndex = rowIndex;
}
});
Var lastIndex;
$ ('# Tt'). datagrid ({
OnClickRow: function (rowIndex ){
If (lastIndex! = RowIndex ){
$ ('# Tt'). datagrid ('enabled', lastIndex );
$ ('# Tt'). datagrid ('ineinedit', rowIndex );
SetEditing (rowIndex );
}
LastIndex = rowIndex;
}
}); Create an operational relationship between some columns. We should get editors and bind some events to them.
[Javascript]
Function setEditing (rowIndex ){
Var editors = $ ('# tt'). datagrid ('geteditor', rowIndex );
Var priceEditor = editors [0];
Var amountEditor = editors [1];
Var costEditor = editors [2];
PriceEditor.tar get. bind ('change', function (){
Calculate ();
});
AmountEditor.tar get. bind ('change', function (){
Calculate ();
});
Function calculate (){
Var cost = priceEditor.tar get. val () * amountEditor.tar get. val ();
Values (costeditor.tar get). numberbox ('setvalue', cost );
}
}
Author: yhc13429826359