EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Rinat on April 01, 2015, 05:10:11 PM



Title: datagrid Group Rows sorting
Post by: Rinat on April 01, 2015, 05:10:11 PM
Hello!
Can I sort table by group field?

Code:
    $('#table').datagrid({
    groupField:'numout',
            groupFormatter:function(value,rows)
            {
                return value + rows.length + '';
            },
});
});

return
Quote
2
 - items
 - items
 - items
1
 - items
 - items
 - items
3
 -items
 - items
 -items


I would like to

Quote
1
 - items
 - items
 - items
2
 - items
 - items
 - items
3
 -items
 - items
 -items


Title: Re: datagrid Group Rows sorting
Post by: stworthy on April 01, 2015, 05:42:09 PM
You can call 'sort' method to sort the special field.
Code:
$('#table').datagrid('sort', {
  sortName: 'numout',
  sortOrder: 'asc'
});


Title: Re: datagrid Group Rows sorting
Post by: Rinat on April 02, 2015, 12:21:55 PM
Sory, but it is not work
14
9
16
1
9
4
20
....


Title: Re: datagrid Group Rows sorting
Post by: stworthy on April 02, 2015, 07:09:27 PM
Please take a look at this example http://jsfiddle.net/dr8jued4/. It works fine.


Title: Re: datagrid Group Rows sorting
Post by: Rinat on April 03, 2015, 05:11:42 AM
Thanks! Yes, it is work.
 But in my app it is not sorting by natural sort algoritm :(

(https://photos-6.dropbox.com/t/2/AADqt19mSLrQ45Me10QVRh9keHbKCyvdysNawE9uXJXOcw/12/11839582/png/32x32/3/_/1/2/2015-04-03_150732.png/CN7Q0gUgASACIAMoAQ/dz6gvoR1xVmxt4j9WqPJuVBAD23T6fHGRmRwyW8kmyc?size=1024x768)


Title: Re: datagrid Group Rows sorting
Post by: stworthy on April 05, 2015, 03:31:19 AM
Please try to custom the 'sorter' function for your field. The updated example below shows how to achieve this functionality.
http://jsfiddle.net/dr8jued4/1/


Title: Re: datagrid Group Rows sorting
Post by: Rinat on April 06, 2015, 07:26:51 AM
Thanks! It's work!