EasyUI Forum
May 20, 2024, 03:58:39 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: using client sort on datagrid with pagination  (Read 8821 times)
madonna
Newbie
*
Posts: 5



View Profile
« on: April 24, 2014, 02:30:03 PM »

To Whom It May Concern,

I'm using client sort on datagrid but the results look funny.  Here are the results:

(Sort - Desc)

[First 10 records - Page 1]:
RecID:
--------
99
9
8
7
14
13
12
11
100
10

[Second 10 records - Page 2]:
RecID:
--------
6
5
4
3
2
1

(Sort - Asc)

[First 10 records - Page 1]:
RecID:
--------
10
100
11
12
13
14
7
8
9
99

[Second 10 records - Page 2]:
RecID:
--------
1
2
3
4
5
6

It seems that when it comes to a single digit the logic is fine, but when is more than one digit the logic is acting funny ('fine' in one way but funny).  If I set remoteSort="true" it will automatically sort the information in descending order in both pages, but when I hit the column to sort, it will not sort ascending at all - it will always stay as descending.  Not sure if the problem might be on my sql statement in where I'm group by and sort the results desc.   Comments are welcome!

 Here is the table code:
<table id="dg" class="easyui-datagrid" style="width:755px;height:200px" title="My Data" iconCls="icon-save" pagination="true" pageSize="10" pageList="[10,20,30,40,50]" rownumbers="true" singleSelect="true" striped="true" remoteSort="false" sortName="recid" sortOrder="asc" multipleSort="true">
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 24, 2014, 06:53:58 PM »

A better solution to solve your issue is to define your own 'sorter' function for the columns. Please refer to the code below:
Code:
<th data-options="field:'f1',width:80,sortable:true,sorter:function(a,b){return parseInt(a) > parseInt(b) ? 1 : -1;}">C1</th>
<th data-options="field:'f2',width:100,sortable:true">C2</th>
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!