0

所以我有下面的观点。当点击前一个视图的列表中的项目时,将调用此视图。此视图上的列表根据先前的选择进行过滤,但我希望能够将项目添加到包含相同过滤器(存储字段 =“值”)的这些列表中。如何获取它以便在单击按钮并加载新视图时也传递过滤列表的值?

我的视图页面。

Ext.define("MyApp.view.ShowAll", {
  extend: 'Ext.Container',
  requires: ['Ext.NavigationView', 'Ext.dataview.List', 'Ext.layout.HBox', 'Ext.Container'],
  xtype: 'myapp-showall',

  config: {
      layout: 'hbox',
      items: [
        {
        layout: 'fit',
      xtype: 'container',
      itemId: 'listContainer',
      flex: 1,
        items: [
         {
            xtype: 'list',
            store: 'leftStore',
            itemTpl: '{storeField}',
            emptyText: 'No values added yet'
          },
          {
            xtype: 'toolbar',
            docked: 'bottom',
            padding: '5px',
            items: [{ xtype: 'button', itemId: 'addValue', text: 'Add Values', ui: 'confirm', width:'100%' }]
          }
        ]
    },
    {
        style: "background-color: #333;",
        width: 10
    },
    {
    layout: 'fit',
      xtype: 'container',
      itemId: 'listContainerTwo',
      flex: 1,
        items: [
         {
            xtype: 'list',
            store: 'rightStore',
            itemTpl: '{storeField}',
            emptyText: 'No values added yet'
          },
          {
            xtype: 'toolbar',
            docked: 'bottom',
            padding: '5px',
            items: [{ xtype: 'button', itemId: 'addValueRight', text: 'Add Values', ui: 'confirm', width:'100%' }]
          }
        ]
    }
    ]
  }
});

这是我的控制器的一部分(设置商店过滤器)

  showValues: function() {
    this.showValueDetails(arguments[3]);
  },

  showValueDetails: function(record) { 
    var title = "Value: "+record['data']['name'];
    var showValue = Ext.create('MyApp.view.ShowAll', { title: title });
    showValue.setRecord(record);

    var valueName = record['data']['name'];
    var leftStore = Ext.getStore("leftStore"); 
    leftStore.clearFilter();
    leftStore.filter('storeField', valueName); 

    var rightStore = Ext.getStore("rightStore"); 
    rightStore.clearFilter();
    rightStore.filter('storeField', valueName); 

    this.getMain().push(showValue);

},

它正确设置页面标题并过滤商店。我只是不确定如何传递一个变量,所以当单击按钮时,valueName(来自控制器)被传递到下一个视图。

4

1 回答 1

0

由于我能够使用上面的代码很好地设置标题,因此一旦我单击提交按钮,只需执行以下操作即可获取标题。

    var titleVariable = Ext.getCmp('ShowAll')['title'];
于 2012-11-01T02:23:18.317 回答