Sorting the Grouped data in GridPanel of EXTJS by group_sort_order

断了今生、忘了曾经 提交于 2019-12-30 04:35:25

问题


How to sort the EXT JS Grid Panel grouped data by its sortOrder

{Grouped data}                {Sort Order}

Audi                            [3]
    col11 col22 xol33
    col21 col23 cole3
Benz                            [1]
    col23 col32 cos32
    col32 dos34 sdfd2
Citron                          [4]
    jkj23 dfd23 fds23
    jkjkk jjkkk jkkkk
Nissan                          [2]
    col23 col32 cos32
    col32 dos34 sdfd2

Fot the above data I want to by sort its sort order (as i got sort order for each group element in my groupdatastore) as below

 Benz                            [1]
    col23 col32 cos32
    col32 dos34 sdfd2
 Nissan                          [2]
    col23 col32 cos32
    col32 dos34 sdfd2
 Audi                            [3]
    col11 col22 xol33
    col21 col23 cole3
 Citron                          [4]
    jkj23 dfd23 fds23
    jkjkk jjkkk jkkkk

回答1:


Try setting these on the store:

remoteGroup:true,
remoteSort: true

And in you sql or what you use to get data out sort by grouping field first.

gridDataStoreObj = new Ext.data.GroupingStore(
{
    remoteGroup:true,
    remoteSort: true,
    proxy: new Ext.data.HttpProxy({url: 'index.php' }),
    method:'POST',
    groupField:'brandName',
    ...     
    sortInfo:{field: 'id', direction: "ASC"},
}); 

On the server:

select * from table order by brandName, id

This should sort groups themselves.




回答2:


For extjs 4 and for local sorting, instede of using: groupField: 'mygroupfield' on the store

use:groupers: [{ property: 'tasklist_id', sorterFn: function(o1, o2){} }]




回答3:


In the store use the sort order column as your groupField.

In the grid:

features: [
  {
    ftype: 'grouping',
    groupHeaderTpl: [
      '{[values.rows[0].groupId]}'
    ]
  }
]

Where groupId is the 'id' of the column that you want to display




回答4:


in GroupingStore set property:

sortInfo: {field: 'Sort_order', direction: 'ASC'},

http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.GroupingView



来源:https://stackoverflow.com/questions/5507005/sorting-the-grouped-data-in-gridpanel-of-extjs-by-group-sort-order

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!