Title: How can formatter the datagrid row value.
Post by: frankgao on February 05, 2016, 08:05:47 AM
I want to format the quantity cell for dynamic. like 1 row, the precision value is 2, When input the quantity=10,the quantity cell display 10.00 2 row, the precision value is 3, When input the quantity=11,the quantity cell display 11.00 columns: [[ { field: 'peid', hidden: true, title: 'ID' }, { field: 'code', title: 'Code', width: '110px', sortable: true }, { field: 'name', title: 'Name', width: '120px', sortable: true }, { field: 'model', title: 'Model', width: '140px', sortable: true }, { field: 'precision', title: 'Precision', width: '70px' }, { field: 'qty', title: 'Quantity', width: '100px', editor: { type: 'numberbox', options: { required: true, formatter: function (value, row, index) { return parseFloat(value).toFixed(row.precision); } } } },
Title: Re: How can formatter the datagrid row value.
Post by: stworthy on February 07, 2016, 12:23:26 AM
Please refer to the code below: $('#dg').datagrid({ onBeginEdit: function(index,row){ var ed = $(this).datagrid('getEditor',{index:index,field:'listprice'}); var opts = $(ed.target).numberbox('options'); $.extend(opts, { formatter: function(value){ return parseFloat(value).toFixed(row.precision); }, parser: function(s){ return parseFloat(s).toFixed(row.precision); } }) } })
|