Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Model view controller ExtJS4-带有JSON绑定到按钮的MVC工具栏_Model View Controller_Extjs_Extjs4 - Fatal编程技术网

Model view controller ExtJS4-带有JSON绑定到按钮的MVC工具栏

Model view controller ExtJS4-带有JSON绑定到按钮的MVC工具栏,model-view-controller,extjs,extjs4,Model View Controller,Extjs,Extjs4,我有一个MVC应用程序,它将工具栏、选项卡面板和导航面板绑定到视口中。在工具栏中,我需要一个带有会话用户名称的注销按钮。所以我请求服务器。我为工具栏控制器设置了存储和模型: Ext.define('Cc.controller.Headers', { extend: 'Ext.app.Controller', stores: ['Person'], models: ['Agent'], views: ['Header'], refs: [ { ref: 'hea

我有一个MVC应用程序,它将工具栏、选项卡面板和导航面板绑定到视口中。在工具栏中,我需要一个带有会话用户名称的注销按钮。所以我请求服务器。我为工具栏控制器设置了存储和模型:

Ext.define('Cc.controller.Headers', {
  extend: 'Ext.app.Controller',

  stores: ['Person'],

  models: ['Agent'],

  views: ['Header'],

  refs: [
    { ref: 'head', selector: 'head' },
    { ref: 'logoutButton', selector: 'head button[action=logout]'}
  ],

  init: function() {
    this.control({
      'head button[action=logout]': {
          beforerender: this.initLogoutButton
      }
    });
  },

  initLogoutButton: function(a){
    this.getPersonStore().load();
    var store = this.getPersonStore().each(),
        button = this.getLogoutButton();
     **//how to bind data to the button ?**
  }
});

@基里洛斯我不明白你的问题。也许有人做过或者考虑过用EddieUp更新它,你想把用户的用户名放在按钮上,你想向服务器请求这个信息(我猜这个信息来自会话变量)。您是否考虑使用Ext.Ajax请求?然后呢?为什么不使用那个数组而不是存储呢?好的,在这种情况下,我更喜欢使用全局数组来存储信息。那么请求放在哪里呢?初始化按钮时,可以尝试放一个Ext.Ajax请求,并使用服务器返回的值来设置按钮文本(button.setText(value)应该可以工作)。