Javascript 在Dojo Dijit中填充依赖组合框?
我有一个dojo组合框,当选项更改时,我需要填充一个相关的第二个组合框 这取决于第一个组合框的值。我怎样才能做到这一点。到目前为止,我尝试过的代码如下 html代码:Javascript 在Dojo Dijit中填充依赖组合框?,javascript,dojo,Javascript,Dojo,我有一个dojo组合框,当选项更改时,我需要填充一个相关的第二个组合框 这取决于第一个组合框的值。我怎样才能做到这一点。到目前为止,我尝试过的代码如下 html代码: <div class="gis_SearchDijit"> <div class="formContainer"> <div data-dojo-type="dijit.form.Form" data-dojo-attach-point="searchFormDijit">
<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>
注意:以上只是我的widjet.js代码的一部分。
我能够加载带有选项的第一个组合框。所以现在,当我在第一个组合框中选择“Cust Data”时,custid应该是第二个组合框中的唯一选项。以同样的方式,第一个是所有者数据,第二个是所有者id……但到目前为止,我无法填充第二个组合框。。有人能给我引路吗
您应该使用第二个组合的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
});
var CmbCustomerAttribute = registry.byId("Attributes");
CmbCustomerAttribute.set("store", store);
CmbCustomerAttribute.set("query", {id:'nonExistantId'}); //so nothing shows in the combo
编辑:在上面的代码片段中引用有助于消除“filteringProperty”的歧义
我还建议用类似这样的东西来填充Begging中的第二个组合
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
});
var CmbCustomerAttribute = registry.byId("Attributes");
CmbCustomerAttribute.set("store", store);
CmbCustomerAttribute.set("query", {id:'nonExistantId'}); //so nothing shows in the combo
我想这正是你想要的,任何疑问都可以问。由于没有小提琴或实际代码,我不能说更多了对不起,里卡多..我的错是,我已经放弃了早些时候添加Html代码。我已经编辑了我之前的问题。谢谢你的回答。希望我的问题现在清楚了。那么你是在尝试创建一个可重用的小部件吗?因为如果不是的话,它看起来太复杂了,那么你使用的是什么版本的dojo?是的,ricardo,我正计划将它用作可重用的小部件。我在2天前就开始了关于这个dojo的培训,因此我的知识有限。原因是我需要使用不同的功能填充这两个组合框是为了以后重用它们。发布问题的主要目的是在customer combobox的onchange事件期间填充attributes combobox。谢谢你,里卡多