EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: ui_user on December 15, 2013, 10:00:08 PM



Title: jeasyui numberbox
Post by: ui_user on December 15, 2013, 10:00:08 PM
Hi Team,

i am new to jquery and jeasyui. i am using easyui-numberbox. i have mentioned the precision as 4. But even though if the value coming from database is 1.25, the value in the ui is getting displayed as 1.2500. Is there any way to avoid this?

Please help me with this.

Thanks
user


Title: Re: jeasyui numberbox
Post by: stworthy on December 15, 2013, 11:37:16 PM
Setting 'precision' to 4 means that the digit number after decimal separator is 4. You can override the 'formatter' function to customize your implementation.
Code:
<input class="easyui-numberbox" value="1.25" required data-options="
precision:4,
formatter:function(value){
var value = $.fn.numberbox.defaults.formatter.call(this,value);
value = parseFloat(value);
return value;
}">


Title: Re: jeasyui numberbox
Post by: ui_user on December 16, 2013, 03:57:48 AM
Thank you stworthy .

It worked, But when the filed is focuses (cursor is placed for editing), then the value is again getting set with precision as 4.

Regards,
user


Title: Re: jeasyui numberbox
Post by: stworthy on December 16, 2013, 05:14:10 PM
Please refer to this example http://jsfiddle.net/c3HDF/. It works as what you expected.


Title: Re: jeasyui numberbox
Post by: ui_user on December 17, 2013, 04:11:43 AM
Thank you.