ExtJS 4 - store.load时获取按钮

时间:2013-02-20 15:52:34

标签: extjs4

你可以帮我做这样的事吗

{
    xtype : 'button',
    text  : 'Prikazi',
    handler : function(item,el){
       this.setDisabled(true);
       store.load(function(records, operation, success) {
           if(success){ this.up('button').setDisabled(false); }
       });
    }
}

问题: this.up('button')

1 个答案:

答案 0 :(得分:1)

只需使用您传递的参数 -

因为'this'首先指向按钮,而在回调中它指的是商店:

{
   xtype:  'button',
   text:   'Refresh',
   id:     'btn_refresh',
   handler: function(clicked_button, the_event) {

      clicked_button.setDisabled(true);

      store.load(function(records, operation, success) {
         if(success){
            clicked_button.setDisabled(false);
         }
      });

   }
}

使用商店的beforeload事件来控制按钮状态可能会更优雅。

更新:更改变量名称以使示例更加明显。

也许结帐FireBugChrome Developer Tools一次

...请接受答案,以防它应该有用。