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

qkf9rpyu  于 2022-12-16  发布在  Dojo
关注(0)|答案(1)|浏览(171)

我有一个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的代码的一部分。我能够加载第一个组合框的选项。所以现在当我选择'客户数据'在我的第一个组合框,然后custid应该是唯一的选项在第二个组合框。同样的方式,业主数据在第一个,然后业主ID在第二个...但到目前为止,我不能填充第二个组合框。有谁能比你先指引我吗

oknwwptz

oknwwptz1#

应该使用第二个组合的query属性,它应该如下所示

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

编辑:上面代码片段中引用的教程帮助清除了“filteringProperty”的歧义。
我也建议从一开始就用这样的东西填充你的sencond组合

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

我想像这样的事情就是你所追求的,任何疑问都可以问。因为不能说更多的没有小提琴或实际的代码

相关问题