Question

When I press a grid's delete button, the row disappears from the grid but when grid is reloaded that row reappears. I tried a lot of commands with no results. Please help! Thanks in advance.

This is the function that creates the grid:

// create the data store
var store = new Ext.data.Store({
    proxy: new Ext.ux.data.PagingMemoryProxy(myData),
    remoteSort:true,
    sortInfo: {field:'del', direction:'DESC'},

    reader: new Ext.data.ArrayReader({
        fields: [
           {name: 'id'},
           {name: 'name'},
           {name: 'category'},
           {name: 'price', type: 'float'},
           {name: 'active', type: 'int'},
           {name: 'actions', type:'text'}
        ]
    })
});

And here is the remove function:

        buttons: [{
        text: 'Add',
        iconCls: 'silk-add',
        handler: this.onAdd

    }, '-', {
        text: 'Delete',
        iconCls: 'silk-delete',
                   handler: function(sm, rowIdx,r){

            var s = grid.getSelectionModel().getSelections();
            for(var i = 0, r; r = s[i]; i++){

              // store.remove(r);
               var index = store.data.indexOf(r);
               if(index > -1){
                r.join(null);
                store.data.removeAt(index);

            }
                store.modified.remove(r);

            if(index > -1){
                store.fireEvent('remove', store, r, index);     
            } 
                store.destroyRecord(store, r, index);
            }

           store.reload();
        },
    }]
Was it helpful?

Solution

When you reload the grid using the grid.store.reload() method the store is going to reload the data from the source, so in this case it looks like you are using local data (an array or json string?). So yes, you are deleting the record from the store, but then by calling reload you are reinserting those records. Your best bet is to do something where you delete the values out of the object "mydata" and then call reload. That should get rid of the records for you.

OTHER TIPS

I found the solution, how to delete from mydata for ex: myData.splice (1,1);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top