Dojo Dijit中的相关组合框填充
Dependent combo box populating in Dojo Dijit?
我有一个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
我想这样的事情正是你所渴望的,任何疑问都只是问问而已。因为不能说更多的削减小提琴或实际代码
相关文章:
- 以编程方式填充组合框道场 (1.8) 的最佳方法是什么?
- 类型错误:url未定义extjs 4正在填充组合框
- Jqgrid动态组合框填充不起作用
- 组合2个数组,如果它们不重复,则用0填充
- ZK:如何使用JavaScript在客户端填充ZK组合框
- KnockoutJS-根据第一个组合框中选择的值填充第二个组合框
- 如何从选定的组合框中填充文本框
- 当表单控件选项具有多个参数时,如何在组合框中填充所选项目
- 使用用户输入填充组合框
- jQuery 运行函数组合框填充多个组合框
- DHTMLX 动态填充组合
- 在 AngularJS 中填充组合框
- 用 JSON 填充 ExtJS 组合框
- 如何根据 html 页面中组合框中的值填充文本框的值
- Jquery组合框填充文本框
- 如何组合来自三个不同字段的值,并仅在所有三个字段都填充值时才将其设置为隐藏字段
- JavaScript 用 ajax 填充组合框,但在 C# 中,所选值为 null
- 使用组合框填充另一个组合框,以便用户可以运行查询
- 如何从多维数组填充列表框(组合框)
- 根据组合框中的选定值自动填充表单,使用 Jquery 和 Ajax