dgrid自定义排序问题 [英] dgrid custom sort issue

查看:93
本文介绍了dgrid自定义排序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试覆盖kfranqueiro在此链接中建议的dgrid中的排序逻辑- https ://github.com/SitePen/dgrid/issues/276

I'm trying to override the sort logic in dgrid as suggested by kfranqueiro in this link - https://github.com/SitePen/dgrid/issues/276.

我从服务器上按排序后的顺序获取数据,只想更新列标题的用户界面。我正在这样做-

I get the data from the server in sorted order and just want to update the UI of column header. I'm doing this -

On(mygrid, 'dgrid-sort', lang.hitch( this,function(event){
    var sort = event.sort[0];
    var order = this.sort.descending ? "descending" : "ascending";
    console.log("Sort "+ this.sort.property + " in " +order+" order.");
    event.preventDefault();
    mygrid.updateSortArrow(event.sort, true);
    myFunctionToRefreshGrid();
}));
...
myFunctionToRefreshGrid: function() {
   ...//get data from server in sorted order
   var mystore = new Memory({data: sortedDataFromServer, idProperty: 'id'});
   mygrid.set("collection", mystore);
   ...
}

内存 dstore / Memory 。我正在使用 dgrid 0.4, dstore 1.1 dojo 1.10.4

Memory here is "dstore/Memory". I'm using dgrid 0.4, dstore 1.1 and dojo 1.10.4

在调用 set('collection',...)之前,我看到 sortedDataFromServer 处于所需的排序顺序。但是由于某些原因,网格中的顺序是不同的。例如,当按降序排序时,我看到以小写开头的值首先以降序出现,然后以大写开头的值按排序次序出现。似乎dstore正在做更多事情。

Before calling set('collection',...) I see that sortedDataFromServer is in the desired sorted order. But for some reason, the order in the grid is different. For example, when sorted in descending order, I see that the values starting with lower case appear first in descending order and then the values starting with upper case appear in sorted order. It looks like dstore is doing something more.

可能会发生什么?难道我做错了什么?

What could be going on? Am I doing something wrong? Is there a different/better way to do custom sorting?

谢谢,

推荐答案

这就是我最终解决该问题的方式-
如所怀疑,收集/存储正在对我的数据进行进一步排序,因此出现不一致的情况。我如下所示自定义存储(内存),并在将数据设置到网格时使用自定义存储。

This is how I ended up addressing the situation - As suspected, the collection/store was further sorting my data and hence the inconsistency. I customized the store (Memory) as shown below and use the custom store when setting data to my grid.

var CustomGridStore = declare([Memory],{
    sort: function (sorted) {
        sorted = [];//Prevent the collection from sorting the data
        return this.inherited(arguments);
    }
});

这篇关于dgrid自定义排序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆