javascript 通过group_sort_order对EXTJS的GridPanel中的分组数据进行排序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5507005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 17:26:16  来源:igfitidea点击:

Sorting the Grouped data in GridPanel of EXTJS by group_sort_order

javascriptextjs

提问by Jemsworld

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

如何按 sortOrder 对 EXT JS Grid Panel 分组数据进行排序

{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

对于上述数据,我想对其排序顺序进行排序(因为我对 groupdatastore 中的每个组元素进行了排序),如下所示

 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

采纳答案by Dasha Salo

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.

在你的 sql 或你用来获取数据的内容中,首先按分组字段排序。

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.

这应该对组本身进行排序。

回答by Ruslan Talpa

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

对于 extjs 4 和本地排序,不要使用: groupField: 'mygroupfield'在商店中

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

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

回答by Dave

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

在商店中使用排序顺序列作为您的 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

其中 groupId 是您要显示的列的“id”

回答by bensiu

in GroupingStore set property:

在 GroupingStore 设置属性中:

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

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

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