Dojo Dijit中的相关组合框填充

Dependent combo box populating in Dojo Dijit?

本文关键字:组合 填充 Dijit Dojo      更新时间:2023-09-26

我有一个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 Data,然后是Owner_id。。。但到目前为止,我无法填充第二个组合框。。有人能指引我吗比你提前

您应该使用第二个组合的查询属性,它应该看起来像这个

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

EDIT:上面代码片段中引用的教程有助于澄清"filteringProperty"的歧义。

我也建议从一开始就用这种来填充你的第二个组合

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

我想这样的事情正是你所渴望的,任何疑问都只是问问而已。因为不能说更多的削减小提琴或实际代码