Question

Using ExtJs4.1 on Sencha Architect.

I have following code in my onDeleteButton code

onDeleteButtonClick: function(button, e, options) {
     var active = this.activeRecord;
     var myGrid = Ext.getCmp('publisherResultsGridView'),
         sm = myGrid.getSelectionModel(),
         selection = sm.getSelection(); // gives you a array of records(models)

     if (selection.length > 0){
            for( var i = 0; i < selection.length; i++) {
                            this.application.log('OnDeleteItemID is ' + selection);
            }
            this.remove(selection);
     }

Code for Remove Function

remove: function(record) {
        var store = Ext.getStore('PublisherProperties');
        store.proxy.url = MasterDataManager.globals.url + "Publishers/";
        store.remove(record);
        store.sync();

When I run it, I could see an array of objects in my log, also I dont get any errors after the remove function is executed. But the store doesnt update, I mean it doesnt remove the selected items.

Can somebody please help me.

Thanks

Was it helpful?

Solution

I solved my problem by making the following changes.

To onDeleteButtonClick

if (selection.length > 0){
                for( var i = 0; i < selection.length; i++) {
                                this.application.log('OnDeleteItemID is ' + selection[i].data.id);
                                this.remove(selection[i]);
                }

         }

To Remove function

remove: function(record) {
    var store = Ext.getStore('PublisherProperties');
    this.application.log('Remove Function is ' + record);
    store.proxy.url = MasterDataManager.globals.url + "Publishers/" + record.data.id;
    store.load({
                        scope : this,
                        callback : function(records, operation, success){
                            if (records.length > 0){
                                var store2 = Ext.getStore('PublisherProperties');
                                        store2.proxy.url = MasterDataManager.globals.url + "Publishers/";
                                        store2.remove(records[0]);
                                        store2.sync();
                             }
                        }
            });
    //store.remove(record);
    //store.sync();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top