0

我有一个 ExtJS4 应用程序,其中一个控制器 (ControllerA) 正在加载另一个 (ControllerB)。控制器 A 有一些我需要在 ControllerB 中设置的用户输入,以便当 ControllerB 加载下拉菜单时,它可以默认将这些下拉菜单跳转到正确的值。

我可以很好地从 ControllerA 传递值:

itemClick: function itemClick(distributor, product) {
  var ctrlr = this.getController('Internal.controller.Popup');
  var win = ctrlr.openWin(distributor, product);
  ctrl.init();
}

openwin 函数获取值,我只是不确定如何在该函数中保存这些值,以便 ControllerB 中的其他函数可以检查它们是否存在,如果存在,则适当设置组合框,例如:

openWin: function openWin(distributor, product) {
  var win = Ext.create('Ext.window.Window', {
    ...
  });
  // Somehow set distributor and product
  return win;
}
loadDistributorBox: function loadDistributorBox(str) {
  //Listener for Ajax load of combobox values
  var combobox = Ext.ComponentQuery.query('combobox')[0];
  var items = str.getRange();
  if (isset(distributor)) {
    // Move the pulldown to the item that matches
  } else {
    // Show the default first value
  }
}
4

1 回答 1

1

First

Init the controller before you call any other function.

itemClick: function itemClick(distributor, product) {
  var ctrlr = this.getController('Internal.controller.Popup');
  ctrl.init();
  var win = ctrlr.openWin(distributor, product);
}

Second

Check if you have the arguments and set them. For that you can use the setValues methods of the baseform

openWin: function openWin(distributor, product) {
  var win = Ext.create('Ext.window.Window', {
    ...
  });
  var form = win.down('form').getForm();
      setObj = {};
  if (distributor) {
     setObj['DistributorFieldName'] = distributor;
  }

  if (product) {
     setObj['ProductFieldName'] = product;
  }
  // set the values
  form.setValue(setObj );

  return win;
}
于 2012-11-19T15:18:04.103 回答