我想重新排序 ExtJs 网格中的行?

I want to Reorder Rows in an ExtJs grid?

我正在使用 ExtJs 4.2,我有一个 Ext.grid.Panel 并且我有数据传入,但我希望它们在摄取时根据一个布尔标志进行排序,其中一个字段为 true top,下一个字段为 true,两个字段都为 false 在底部。到目前为止,我已经按照下面的规定编辑了分类器。

me.requesterListStore = new Ext.create('Ext.data.Store', {
        id: 'requesterListStore',
        model: 'Connex.Request.Model.RequesterModel',
        buffered: true,
        pageSize: 100,
        leadingBufferZone: 50,
        autoLoad: false,
        remoteFilter: false,
        purgePageCount: 5,
        remoteSort: false,
        sortOnLoad: true,
        sorters: [
            {
                property: 'isSmartIndexed',
                direction: 'DESC'
            },
            {
                property: 'isAutoIndexed',
                direction: 'DESC'
            }
        ],
        proxy: {
            type: 'ajax',
            url: $context + 'services/requester/search',
            actionMethods: {
                read: 'POST'
            },
            doRequest: function (operation, callback, scope) {

                var writer = this.getWriter(),
                    request = this.buildRequest(operation, callback, scope);

                if (operation.allowWrite()) {
                    request = writer.write(request);
                }

                Ext.apply(request, {
                    headers: this.headers,
                    timeout: this.timeout,
                    scope: this,
                    callback: this.createRequestCallback(request, operation, callback, scope),
                    method: this.getMethod(request),
                    jsonData: this.jsonData,
                    disableCaching: false // explicitly set it to false, ServerProxy handles caching
                });
                Ext.Ajax.request(request);
                return request;
            },
            reader: {
                type: 'json',
                root: 'content',
                totalProperty: 'total',
                idProperty: 'id'
            },
            writer: {
                writer: new Ext.data.JsonWriter({
                    getRecordData: function (record) {
                        return record.data;
                    }
                })
            }
        }

    });
sorters: [{
    property: 'isSmartIndexed',
    direction: 'DESC' // or 'ASC'
}, {
    property: 'isAutoIndexed',
    direction: 'DESC' // or 'ASC'
}]

将这些分拣机添加到您的商店。

真总是大于假 ;)

请注意,您不能像此处写的那样在 bufferedStore 上使用 sortingFuntions:

If the store is buffered, then prefetchData is stored by index, this invalidates all of the prefetchedData.

因为在您的情况下,您将只订购网格上显示的数据,而不是将要加载的其他数据。

Test it in this fiddle.