在Dojo Dijit中填充的依赖组合框?

问题描述 投票:0回答:1

我有一个dojo组合框,当选项被更改时,我需要填充一个相关的第二个组合框,它取决于第一个组合框的值。我怎样才能做到这一点。我到目前为止尝试的代码如下

HTML代码:

<div class="gis_SearchDijit">
<div class="formContainer">
    <div data-dojo-type="dijit.form.Form" data-dojo-attach-point="searchFormDijit">
        <table cellspacing="5" style="width:100%; height: 49px;">
            <tr>
                <td>                       
                    <label for="Customer">Customer:</label>                                        
                      <div data-dojo-type="dijit.form.ComboBox" id="Customer"></div> <br />  
                    <label for="Attributes">Search Attribute:</label>      
                     <div data-dojo-type="dijit.form.ComboBox" id="Attributes"></div>                     

                    <br />
                    Enter Attribute Value:<input id="searchText" type="text" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="name:'searchText',trim:true,required:true,style:'width:100%;'"
                    />
                </td>
            </tr>
        </table>
    </div>
</div>

<div class="buttonActionBar">
        <div data-dojo-type="dijit.form.Button" data-dojo-props="busyLabel:'searching',iconClass:'searchIcon'" data-dojo-attach-event="click:search">
                Search
        </div>
</div>

postCreate: function () { 
                    this.inherited(arguments); 


                    this.populateCmbCustomer(Memory); 

                    var comboBoxDigit = registry.byId("Customer"); 


                    comboBoxDigit.on('change', function (evt) { 
                        alert('on change'); //This alert is triggerd 
                        this.populateCmbCustomerAttribute(Memory); 

                    }); 

   populateCmbCustomer: function (Memory) { 
                var stateStore = new Memory({ 
                    data: [ 
                { name: "Cust  Data", id: "CUST" }, 
                { name: "Owner Data", id: "Owner" }, 
                { name: "Applicant", id: "Applicant" }                     
                    ] 
                }); 

                var comboBoxDigit = registry.byId("Customer");     
                //console.log("COMBO: ", comboBoxDigit); 
                comboBoxDigit.set("store", stateStore); 
            }, 



                 populateCmbCustomerAttribute: function (Memory) { 
                var custAttribute = new Memory({ 
                    data: [ 
                { name: "Custid", id: "Cust" }, 
                { name: "Applicant Id", id: "Applicant" }, 
                { name: "Owner_Id", id: "Owner" } 

                    ] 
                }); 

                var CmbCustomerAttribute = registry.byId("Attributes"); 
                CmbCustomerAttribute.set("store", custAttribute); 
            }, 

注意:以上只是我的widjet.js代码的一部分。我可以使用选项加载第一个组合框。所以现在当我在我的第一个组合框中选择“Cust Data”时,custid应该是第二个组合框中的唯一选项。以同样的方式,所有者数据在第一个然后Owner_id在第二...但到目前为止,我无法填充第二个组合框..可以有人请提前指导我比你

javascript dojo
1个回答
0
投票

你应该使用第二个组合的查询属性,它应该是这样的

comboBoxDigit.on('change', function (evt) { 
   var CmbCustomerAttribute = registry.byId("Attributes");
   CmbCustomerAttribute.set("query", {filteringProperty: this.get('value')}); //if you dont understand this check out the stores tutorials
});

编辑:上面的代码片段中引用的tutorials有助于清除“filteringProperty”的歧义。

我还建议从一开始就用这样的东西填充你的第二个组合

var CmbCustomerAttribute = registry.byId("Attributes");
CmbCustomerAttribute.set("store", store); 
CmbCustomerAttribute.set("query", {id:'nonExistantId'}); //so nothing shows in the combo

我认为这样的事情就是你在寻找的,任何疑问都会问。没有小提琴或实际代码就不能说更多

© www.soinside.com 2019 - 2024. All rights reserved.