Adding custom logic after deleting a row on a Grid

42 views
Skip to first unread message

Jorge Segura

unread,
Feb 10, 2014, 6:33:28 PM2/10/14
to net...@googlegroups.com
Hi. In **Netzke Grid** I'm trying to execute some custom logic right after pressing the ok button at the confirmation window.

I just copy&paste the code located at netzke-basepack-0-8/lib/
netzke/basepack/grid/javascripts/event_handling.js, just like this getting the following error: this.deleteData is not a function...


    js_configure do |c|
        c.on_delete_action = <<-JS
            function(record){
               this.getSelectionModel().select(record);
               this.onDel();
        }
        JS

        c.on_del = <<-JS
        function() {
        Ext.Msg.confirm(this.i18n.confirmation, this.i18n.areYouSure, function(btn){
          if (btn == 'yes') {
            var records = [];
            this.getSelectionModel().selected.each(function(r){
              if (r.isNew) {
                // this record is not know to server - simply remove from store
                this.store.remove(r);
              } else {
                records.push(r.getId());
              }
            }, this);

            if (records.length > 0){
              if (!this.deleteMask) this.deleteMask = new Ext.LoadMask(this.getEl(), {msg: this.deleteMaskMsg});
              this.deleteMask.show();
              // call API
              this.deleteData({records: Ext.encode(records)}, function(){
                this.deleteMask.hide();
              },

                //////////////////////////
            //Here: my custom logic!//                   
            //////////////////////////
          }   
        }, this);
      }
    JS
    end

what I'm I doing wrong?
Thanks in advance.
Message has been deleted

Praveen K

unread,
Feb 11, 2014, 4:25:54 AM2/11/14
to net...@googlegroups.com
Hi Jorge,

Instead of adding js method in ruby config method property setting, add it as normal js method in class.

EX:

class BossGrid < Netzke::Basepack::Grid
  def config
  end

  js_method :on_del,<<-JS
    function(){
      //code to delete records and custom statements
    }
  JS

end
Reply all
Reply to author
Forward
0 new messages