EasyUI Forum
September 14, 2025, 04:38: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: cell "format" as an attribute of column in datagrid  (Read 7296 times)
mshaffer
Newbie
*
Posts: 21


View Profile
« on: December 12, 2016, 10:17:51 AM »

Hi,

I am trying to sort data that I have built in HTML...

The sorting is "as a string"... that is "73" and "7" are before "6"...

In your data examples, when you put in the data field, it works as expected, but in the table format, it does not.

In the data examples, you can do "type of" ... which is not possible with table, so I propose adding type-of as a column attribute
Code:
if(typeof(data) == 'number')  
if(typeof(data) == 'boolean')

In the same vain, your sorter: true, with asc and desc ... you should also have default methods of "alpha" or "numeric" with custom functions to override.

Code:
field:'freq', align: 'center',sortable:true, order:'desc', format:'number'



Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #1 on: December 12, 2016, 05:09:14 PM »

The 'sorter' function can be used to custom your sort on a field. The code below shows how to sort a 'date' field.
Code:
$('#dg').datagrid({
remoteSort: false,
columns: [[
{field:'date',title:'Date',width:80,sortable:true,align:'center', 
sorter:function(a,b){ 
a = a.split('/'); 
b = b.split('/'); 
if (a[2] == b[2]){ 
if (a[0] == b[0]){ 
return (a[1]>b[1]?1:-1); 
} else { 
return (a[0]>b[0]?1:-1); 

} else { 
return (a[2]>b[2]?1:-1); 


}
]]
});
Logged
mshaffer
Newbie
*
Posts: 21


View Profile
« Reply #2 on: December 12, 2016, 05:39:53 PM »

Yes, that was my workaround after finding out "table data" and "direct data" behave differently.

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!