EasyUI Forum
May 17, 2024, 11:34:56 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: Can I format datagrid in edit mode?  (Read 10577 times)
jimmywon
Newbie
*
Posts: 11


View Profile
« on: January 26, 2014, 01:11:48 AM »

Can I format a decimal number, 2.300 to 2.3,
In datagrid edit mode?

JIMMY
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: January 26, 2014, 07:44:06 PM »

Please try to use 'numberbox' editor with 'precision' property set to 1.
Code:
$('#dg').datagrid({
columns:[[
{field:'listprice',title:'ListPrice',width:80,align:'right',
editor:{
type:'numberbox',
options:{
precision:1
}
}
}
]]
});
Logged
jimmywon
Newbie
*
Posts: 11


View Profile
« Reply #2 on: January 26, 2014, 07:56:13 PM »

Sorry,

I like to input 3 prescision , but trim tail 0,
Like easyui-numberbox formater:
    data-options="precision:3,
                    formatter:function(value){
                      var value = $.fn.numberbox.defaults.formatter.call(this,value);
                      value = parseFloat(value);
                      return value;}"
how to do this in datagrid edit mode?

Jimmy
Logged
jimmywon
Newbie
*
Posts: 11


View Profile
« Reply #3 on: January 28, 2014, 09:45:21 AM »

ok, I found the formatter
in editor options, ex:

<th data-options="field:'saleprc',align:'right',width:80,
                  formatter: function(value,row){
                    if (!isNaN(parseFloat(value))){return parseFloat(value);}
                  }"
                  editor="{
                  type:'numberbox',
                  options:{precision:3,
                  formatter:function(value){
                    if (!isNaN(parseFloat(value))){return parseFloat(value);}
                  }
                  }}">
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!