Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting extjs6 doSort方法_Sorting_Extjs - Fatal编程技术网

Sorting extjs6 doSort方法

Sorting extjs6 doSort方法,sorting,extjs,Sorting,Extjs,我在Ext6中没有找到关于网格列的doSort函数,在任何升级说明中也没有找到。可能是因为它是一个私有函数,有谁能告诉我,除了doSort在Ext 4中所做的事情之外,还有什么其他方法可以替代 我试着改用分拣机 { text: 'columnText', dataIndex: 'columnIndex', sorter: me.sort } sort: function(v1,v2) { ... } 但我没有在v1、v2参数中找到像dataIndex或colu

我在Ext6中没有找到关于网格列的doSort函数,在任何升级说明中也没有找到。可能是因为它是一个私有函数,有谁能告诉我,除了doSort在Ext 4中所做的事情之外,还有什么其他方法可以替代

我试着改用分拣机

{
    text: 'columnText',
    dataIndex: 'columnIndex',
    sorter: me.sort
}

sort: function(v1,v2) {
    ...
}
但我没有在v1、v2参数中找到像dataIndex或columnName这样的smth来进行排序。(这只是一个模型)

我需要空单元格是从下面排序升序后,空单元格是从上面排序降序后


谢谢。

这里有什么问题?可以使用模型对象检索要排序的列数据。从文档中:

sorter: function(record1, record2) {
    var name1 = record1.data.columnIndex;
    var name2 = record2.data.columnIndex;
    return name1 > name2 ? 1 : (name1 === name2) ? 0 : -1;
}
编辑:如果您不想为每一列重写此内容,则可以执行以下操作:

sorter: (function(columnIndex){ return function(v1, v2){ me.sort(v1, v2, columnIndex);} })("column1")
    fields: [{
        name: "textField",
        type: 'string',
        //sortType: 'asInt'
    }]

现在,您可以将列名作为排序函数中的第三个参数。

您希望对存储进行排序,而不是对列进行排序。请看一下ExtJS 4中的doSort函数:

doSort: function(state) {
    var tablePanel = this.up('tablepanel'),
        store = tablePanel.store;

    // If the owning Panel's store is a NodeStore, this means that we are the unlocked side
    // of a locked TreeGrid. We must use the TreeStore's sort method because we cannot
    // reorder the NodeStore - that would break the tree.
    if (tablePanel.ownerLockable && store.isNodeStore) {
        store = tablePanel.ownerLockable.lockedGrid.store;
    }
    store.sort({
        property: this.getSortParam(),
        direction: state
    });
},
/**
 * Returns the parameter to sort upon when sorting this header. By default this returns the dataIndex and will not
 * need to be overriden in most cases.
 * @return {String}
 */
getSortParam: function() {
    return this.dataIndex;
},
现在,这段代码仍然在extjs6中工作,只是它不再是框架的一部分。您可以“将其放回框架中”(例如作为覆盖),它应该可以再次工作。或者您可以直接从列事件中使用相关部分,例如

columns:[{
    dataIndex:'ABC',
    listeners:{
        headercontextmenu:function(ct, column) {
            column.mySortState = column.mySortState=='ASC'?'DESC':'ASC';
            ct.up('grid').getStore().sort({
                property:column.dataIndex;
                direction:column.mySortState
            });
        }
    }
}]

也许您需要在模型中这样定义它:

sorter: (function(columnIndex){ return function(v1, v2){ me.sort(v1, v2, columnIndex);} })("column1")
    fields: [{
        name: "textField",
        type: 'string',
        //sortType: 'asInt'
    }]

我试过了,但是当我把它添加到列代码中时它没有被调用。如果你在fiddle上分享一个简单的例子,我可以提供帮助。我可以做sorter:function(v1,v2){v1=v1.data.columnIndex;v2=v2.data.columnIndex;return v1>v2?-1:(v1