javascript - ExtJS sort grid column of string as float -
i have grid column renders float record field string. so, when sort column, it's sorted string format , therefore, in wrong way:
i've tried different solutions. 1 understand should works use of sorttype function. haven't bee able far...
these important pieces of code.
my model load grid data:
ext.define('ama.model.assetmodel', { extend: 'ext.data.model', fields: [ {name: 'account', type: 'string'}, {name: 'altlabel'}, {name: 'amortizable', type: 'int'}, {name: 'amortizationsvnc', type: 'float', convert: function(value,model){ return parsefloat(math.round(value * 100) / 100).tofixed(2); } }, {name: 'assetsaccountingprice', type: 'float', convert: function(value,model){ return parsefloat(math.round(value * 100) / 100).tofixed(2); } }, .....
my grid columns affected:
items: [{ xtype: 'grid', reference:'grdgestion', id:'grdgestion', //store: assetsstore, //height: ext.getcmp('maincontenedor').lastbox.height-150-50, columns: [{ ..... },{ text: l10n.translate('coste'), flex: 1, sortable: true, dataindex: 'assetsaccountingprice', xtype: 'numbercolumn', decimalprecision: 2, decimalseparation: ',', thousandseparation: '.' }, { text: l10n.translate('vnc'), flex: 1, sortable: true, dataindex: 'amortizationsvnc', renderer: function(value){ return ext.util.format.number(value, '0,000.00'); } }, { .....
neither of 2 coumns sort data expected.
note (maybe useful): string format "0.000,00"
how can solve this?
please see this: fiddle
{ name:'fieldname', type: 'float', sorttype: 'asfloat', // need add convert: function(value,model) { return parsefloat(math.round(value * 100) / 100).tofixed(2); } }
Comments
Post a Comment