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

发布于 2024-12-08 06:14:29 字数 1837 浏览 0 评论 0原文

如果父值具有唯一标识符,我已经链接了组合。 但是,我在父组合中有 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());                                 

                                }  
                            }

I have linked combos that work if the parent value has a unique identifier.
However, I have 4 options in the parent combo that should have the same value for the child combo. I've given these the same identifier in the store, yet the value in the combo doesn't change when I choose any of them.

Is there anyway to do this without duplicating all values?

Stores

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"]
                ];

Combo

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

                                }  
                            }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光下的泡沫是彩色的 2024-12-15 06:14:29

您可以改用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 );

You can use the filterBy function instead. Here's how:

    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 );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文