简体   繁体   English

ExtJS 4.2 - 使用当前变量存储刷新网格

[英]ExtJS 4.2 - Refresh grid with current variable store

I have a gridpanel on a panel window that loads a certain store: 我在面板窗口上有一个加载某个商店的网格面板:

xtype: 'gridpanel',
  store: custStore,
  viewConfig: {
    loadMask: false,
    enableTextSelection: true
  },
  hideHeaders: false,
  bodyBorder: true,
  id: 'playerslist-grid-id',
  itemId: 'playerslist-grid-id',
  viewConfig: {
    deferEmptyText: false,
    emptyText: 'No records yet'
  },
  columns: [{
    text: 'Customer',
    dataIndex: 'username',
    flex: 1
  }, {
    header: '',
    xtype: 'actioncolumn',
    itemId: 'remove-player-btn',
    width: 50,
    sortable: false,
    resizable: false,
    menuDisabled: true,
    hidden: bHide,
    items: [{
      icon: 'resources/img/x.png',
      tooltip: 'Remove Player',
      scope: oMe
    }],
    editor: {
      xtype: 'text',
      name: 'deleteRow'
    }
  }]

The custStore variable is handled like this. custStore变量的处理方式如下。

var oMe = this;
oController = EcommBackoffice.Global.app_var.getController('CustomerTagsController'),
  cStore = oController.getCustomerListStore(),
  cDetails = cStore.first(),
  customers = [];

customers = cDetails.get('customers');

var custStore = Ext.create('Ext.data.ArrayStore', {
  model: 'CustomerList',
  data: customers
});

I needed to put it in an array store as the data object is nested like so: 我需要将它放在数组存储中,因为数据对象是嵌套的,如下所示:

{
  id: 1,
  name: 'test',
  description: 'test',
  customers: [{
    id: 001,
    username: 'bob'
  }, {
    id: 001,
    username: 'terese'
  }, {
    id: 001,
    username: 'dab'
  }, {
    id: 001,
    username: 'bba'
  }, {
    id: 001,
    username: 'hello'
  }]
}

On my controller I process a function that places custStore to it and other parameters before a request . 在我的控制器上,我处理一个函数,在request之前将custStore放到它和其他参数。

click: function() {
  oController.addPlayerToTag(newPlayer, tagId, custStore);
}

Problem : How do I reload custStore on the gridpanel I'm on after a successful callback? 问题 :我该如何重装custStoregridpanel我是一个成功的回调后? I tried using custStore.load() but nothing happened. 我尝试使用custStore.load()但没有任何反应。

If I understand correctly, you get a new array of customers back from the server and need to refresh the grid with that array. 如果我理解正确,您将从服务器返回一个新的客户数组,并需要使用该数组刷新网格。 In that case I think you need to call setData on the custStore, passing in the new array of customers. 在这种情况下,我认为你需要在custStore上调用setData ,传入新的客户数组。 Not sure if 4.2 has this method. 不确定4.2是否有这种方法。 If not, try setting custStore.data property. 如果没有,请尝试设置custStore.data属性。

If that alone doesn't work, try also calling reconfigure on the grid, passing in the custStore. 如果仅此一项不起作用,请尝试在网格上调用reconfigure ,并传入custStore。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM