Search code examples
ruby-on-rails-3extjscheckboxgriddelete-record

extjs checkbox grid delete rails


i am using ExtJS with Rails...I am trying to delete records selected in grid through "Checkbox column"...i dnt have any idea as to how can i handle "Array" of selected records of grid through rails controller...plzz guide me... the code on delete button is as follows :

var sm = prodgrid.getSelectionModel();
delbtn.on("click", function () {
    var sel = sm.getSelections();
    Ext.Ajax.request({
        url: 'products/delete',
        //   method:'DELETE',
        params: {
            'prodid': sel
        }

    });

});

How can i iterate through "sel" array in my Rails controller?? plzz help


Solution

  • use Ext.each to iterate an array :

    var sm = prodgrid.getSelectionModel();
    delbtn.on("click", function () {
        var sel = sm.getSelections();
    
        Ext.each(sel,function(data){
    
            /// your stuff
            Ext.Ajax.request({
               url: 'products/delete',
               //   method:'DELETE',
               params: {
                   'prodid': data.id // the parameter
               }
            }); 
            ///// end       
    
        },this);
    });