【问题标题】:ExtJS 4.2 - Refresh grid with current variable storeExtJS 4.2 - 使用当前变量存储刷新网格
【发布时间】:2017-02-01 09:39:41
【问题描述】:

我在加载某个商店的面板窗口上有一个网格面板:

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'
    }
  }]

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
});

我需要把它放在一个数组存储中,因为数据对象是这样嵌套的:

{
  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'
  }]
}

在我的控制器上,我处理了一个将custStore 放在它上面的函数以及request 之前的其他参数。

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

问题:如何在成功回调后在gridpanel 上重新加载custStore?我尝试使用custStore.load(),但没有任何反应。

【问题讨论】:

  • 你试过 custStore.reload() 吗?
  • 是的。那也没有用。似乎商店正在重新加载,但gridpanel 的实际视图不是。我只想清楚.reload() 是从detailPanel 视图调用的控制器函数中完成的。似乎detailPanel 视图上的gridpanel 无论如何都没有更新。

标签: javascript extjs


【解决方案1】:

如果我理解正确,您会从服务器返回一个新的客户数组,并且需要使用该数组刷新网格。在这种情况下,我认为您需要在 custStore 上调用 setData,并传入新的客户数组。不确定4.2是否有这种方法。如果没有,请尝试设置 custStore.data 属性。

如果仅此一项不起作用,请尝试在网格上调用 reconfigure,并传入 custStore。

【讨论】:

    猜你喜欢
    • 2014-03-28
    • 1970-01-01
    • 2014-01-18
    • 1970-01-01
    • 2014-05-07
    • 2012-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多