javascript - Format Kendo grid column filter for percentages -
i have kendo grid , datasource data returns number unknown decimal places. i'm using parse function on datasource compensate that.
defaultmonocpp: { editable: false, type: "number", parse: function(e) { return kendo.parsefloat(kendo.tostring(e,"p4")); } }
now when filter, don't want automatically multiply percentage 100. have filterable
set on columns.
{ field: "defaultmonocpp", title: "mono cost", format: '{0:p4}', filterable: { ui: function(e) { e.kendonumerictextbox({ //format: "{0:p4}", //format: "p4", format: "##.0000 \\%", decimals: 4 }); } } }
but messes filtered number (1.2700% => 1.27). filtering fails.
jsfiddle clarification: http://jsfiddle.net/dmathisen/mecny50f/
is there way have both parse , filterable work correctly together?
my suggestion format numeric textbox percentage , set step 0.01 increments/decrements 1% @ time. if you're worried user typing in percentage whole number, handle in change event.
e.kendonumerictextbox({ format: '{0:p4}', step: 0.01, decimals: 4, change: function () { var val = this.value(); if (val > 1) { this.value(val / 100); this.trigger("change"); } } });
Comments
Post a Comment