Rally grid with custom column renderer sort

前端 未结 1 849
轮回少年
轮回少年 2021-01-25 03:42

Background

When I try to sort by a column that I have used a custom renderer for, nothing happens - it changes the sort from ASC to DESC and back and fo

相关标签:
1条回答
  • 2021-01-25 04:01

    For the rallygrid config, make sure you set the property of remoteSort, which is by default true, to false. Then, here is the config for the column:

                {dataIndex: 'Parent', name: 'Parent', 
                    doSort: function(state) {
                        var ds = this.up('grid').getStore();
                        var field = this.getSortParam();
                        console.log('field',field);
                        ds.sort({
                            property: field,
                            direction: state,
                            sorterFn: function(v1, v2){
                                console.log('v1',v1);
                                console.log('v2',v2);
                                if (v1.raw.Parent) {
                                    v1 = v1.raw.Parent.Name;
                                } else {
                                    v1 = v1.data.Name;
                                }
    
                                if (v2.raw.Parent) {
                                    v2 = v2.raw.Parent.Name;
                                } else {
                                    v2 = v2.data.Name;
                                }
    
                                return v1.localeCompare(v2);
                            }
                        });
                    },
                    renderer: function(value, meta, record) {
                        var ret = record.raw.Parent;
                        if (ret) {
                            return ret.Name;
                        } else {
                            meta.tdCls = 'invisible';
                            return record.data.Name;
                        }
                    }
                },
    
    0 讨论(0)
提交回复
热议问题