EasyUI Forum
October 15, 2025, 10:36:05 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: datagrid - format a value  (Read 9623 times)
stephenl
Newbie
*
Posts: 40


View Profile
« on: December 15, 2024, 12:02:13 PM »

Hello

I have a datagrid defined as below
                        
Code:
columns:[[
    {field:'Open_Amt',title:'Amt',width:5, align:'right'},
    {field:'Currency',title:'Cur',width:5}
]],

Currently, Open_Amt format shows as 12345.5

I would like to format value this to show 12,345.50

ie always show 2 places after the decimal point and also show thousands separator

Suggestions appreciated

Thank you


Logged
jega
Full Member
***
Posts: 225


View Profile
« Reply #1 on: December 15, 2024, 01:19:17 PM »

Hi.

Use formatter like {field:'Open_Amt',title:'Amt',width:5, align:'right',formatter:formatOpenAmt},

   function formatOpenAmt(row){
      var formattedString = [Find the code you need. There is a lot of possibilities]
      return formattedString;
   }

Look at demo/datagrid/format datagrid columns

OR

If you pull Open_Amt from a database, the format in in your sql so json is already formatted


Logged
stephenl
Newbie
*
Posts: 40


View Profile
« Reply #2 on: December 15, 2024, 01:37:00 PM »


If you pull Open_Amt from a database, the format in in your sql so json is already formatted Huh

Great Idea - Thanks !
Logged
jega
Full Member
***
Posts: 225


View Profile
« Reply #3 on: December 16, 2024, 04:07:37 AM »

You got the point, even if my text was incorrect spelled.

For others.

If data to datagrid is from a database, then format it directly in your SQL or make a view with the formated columns, and return the formatted JSON data directly to the datagrid.

Please mark topic as [SOLVED] ;-)



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!