1

My_grid多くの重複した行が含まれています (同じnameusername、および別の hidden を持つid)。重複した行を削除するには?

4

2 に答える 2

3

プロキシのリーダーまたはモデルのidPropertyを設定する必要があります。

var myStore = Ext.create('Ext.data.Store', {
    proxy: {
        type: 'ajax',
        url: '/myUrl',
        reader: {
            idProperty: 'Id'
        }
    },
    model: 'myModel'
});
于 2013-02-26T12:56:04.520 に答える
1

このスニペットはうまくいけばうまくいきます:

これを使用してストアとグリッドを宣言することが重要です。例えばthis.store = ...

  //Listener on the button removes the duplicated rows
        this.button.on('click', function() {
            this.store.each(function(record) {
                //This is necessary because if this record was removed before
                if(record !== undefined) {
                    //Find all records which have the same name like this record
                    var records = record.store.query('name', record.get('name'));

                    //Remove all found records expect the first record 
                    records = records.each(function(item, index) {
                        //Don't delete the first record
                        if(index != 0) {
                            item.store.remove(item);    
                        }    
                    });    
                }
            }); 
        }, this);
于 2013-03-02T20:14:02.567 に答える