EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: pedroc on April 07, 2015, 08:40:59 AM



Title: set default value in datagrid cells under conditions
Post by: pedroc on April 07, 2015, 08:40:59 AM
I have a datagrid with editable rows and I need each cell by default has the value 0.00 and if clear the value of the cell to another cell the value 0.00 is set


Title: Re: set default value in datagrid cells
Post by: stworthy on April 07, 2015, 06:18:25 PM
The simplest way to solve this issue is to initialize the row values before editing it.
Code:
$('#dg').datagrid({
onBeforeEdit: function(index,row){
row.listprice = row.listprice||0;
row.unitcost = row.unitcost||0;
}
})