EasyUI Forum
September 15, 2025, 07:45:45 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Numberbox precision  (Read 8779 times)
leela
Newbie
*
Posts: 29


View Profile Email
« on: July 16, 2014, 03:06:35 PM »

Hi,

 I am usig precision property for number box. But is there a way to show the number with out decimal points, in case the catual value is an integer and show the decimal places only for floating point number.
Eg: 45.23 should shown as 45.23
     45 should show up as 45 , instead of 45.00

Please advise.


-Leela.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 16, 2014, 03:48:46 PM »

Please override the 'formatter' function to achieve this functionality.
Code:
$('#nn').numberbox({
  formatter:function(value){
var opts= $(this).numberbox('options');
var s = $.fn.numberbox.defaults.formatter.call(this, value);
var idx = s.indexOf(opts.decimalSeparator+'00');
if (idx >= 0){
s = s.substr(0, idx);
}
return s;
  }
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!