Extjs链接组合 - 让父值具有相同的子值

时间:2011-10-05 09:17:24

标签: extjs combobox

如果父值具有唯一标识符,我链接了有效的组合。 但是,我在父组合中有4个选项,它们应该具有相同的子组合值。我在商店中给出了相同的标识符,但是当我选择其中任何一个时,组合中的值都不会改变。

无论如何都要做到这一点而不重复所有值?

店铺

var fields = [
              ["s","Name"],
              ["s","ID"],
              ["cc","City"],
              ["s","Cost"],
              ["r","Status"]
              ];

var operators =[
                [1, "s","begins with"],
                [2, "s","equals"],
                [3, "s","contains"],
                [4, "s","ends with"],
                [5, "cc", "equals"],
                [6, "r", "equals"]
                ];

组合

xtype:'combo',                             
                        id: 'fieldSelecCmb1',                                                   
                        width: 125,                                     
                        displayField: 'field',
                        valueField: 'fid',                      
                        hideLabel: true,  
                        store: storeField ,
                        triggerAction: 'all',
                        mode: 'local',
                        value: "Choose a field",
                        listeners:{ 
                            select: { 
                                fn:function(combo, value){                                         
                                    var id = combo.id;
                                    var rowNo = id.charAt(id.length-1);
                                    var opCombo = Ext.getCmp("optionSelectCmb"+rowNo);
                                    opCombo.clearValue();
                                    opCombo.store.filter("fid", combo.getValue());                                 

                                }  
                            }

1 个答案:

答案 0 :(得分:0)

您可以使用filterBy函数。方法如下:

    opCombo.store.filterBy( function(record, id) {
      if((record.data.id == 1 || record.data.id == 2) && (this.id == 1 || this.id == 2)) {
    // specify index that you want to exclude when getting say parent combo value 1 or 2
          return false; // excludes the record in the store
      } else {
          return true; // includes the record in the store.
      }
    } , combo );