组合框和值相冲突 [英] combobox and Value collided
问题描述
我有错误:列表中的项目具有标识符:[id]。价值相撞:[48]
如果我看看我的原始json,我只有两个对象,id是41和48
,但是当我看到我的ItemFileReadStore我有四个对象,其中之一是对象的id = 41,另外三个是id = 48相同的重复对象
该方法用于ItemFileReadStore是:
var store = new dojo.data.ItemFileReadStore({data:{
identifier:id,
items:data
)});
console.log(store);
var filteringSelect = new dijit.form.ComboBox({
store:store,
searchAttr:nafn
},
nafn) ;
可能是问题的根源是什么?
我观察到你的代码中的某些错误。
1)dojo.data.ItemFileReadStore期望数据具有某种格式你缺少这种格式。
格式将是这样的。
var storeData = {identifier:'uniqueIdOfEachItem',label:'displayName ',items:[
{uniqueIdOfEachItem:1,displayName:'somename'},
{uniqueIdOfEachItem:2,displayName:'somename2'}
]}
var store = new dojo.data.ItemFileReadStore({data:storeData})
var filteringSelect = new dijit.form.ComboBox({
store:store,
searchAttr:displayName
},
id_of_element_in_html_where_your_combo_will_sit);
2)ComboBox中的searchAttr应该是商店项目的一个道具(这里是uniqueIdOfEachItem或displayName)
3)请确保商店中每个商品的标识符(这里uniqueIdOfEachItem)是唯一的,如果它不是唯一的,那么组合框将不起作用,抛出一些错误类似于您提到的错误。
I am using the dojo combobox together with json. I have the error : Items within the list have identifier: [id]. Value collided: [48] If I look at my raw json, I only have two objects which id is 41 and 48 but when I look at my ItemFileReadStore i have four objects, one of them is the object with id=41 and the three others are the same duplicated objects with id=48
the method is use for the ItemFileReadStore is :
var store = new dojo.data.ItemFileReadStore( { data: {
identifier: "id",
items: data
}});
console.log(store);
var filteringSelect = new dijit.form.ComboBox({
store: store,
searchAttr: "nafn"
},
"nafn");
What could be the source of the problem ?
i observed certain errors in your code.
1)dojo.data.ItemFileReadStore expects data to be in certain format you are missing that format. the format will be something like this.
var storeData = {identifier : 'uniqueIdOfEachItem', label : 'displayName', items : [
{uniqueIdOfEachItem:1,displayName:'somename'},
{uniqueIdOfEachItem:2,displayName:'somename2'}
]}
var store = new dojo.data.ItemFileReadStore({data: storeData })
var filteringSelect = new dijit.form.ComboBox({
store: store ,
searchAttr: "displayName"
},
"id_of_element_in_html_where_your_combo_will_sit");
2)searchAttr in ComboBox should be one of the props of the store item (here uniqueIdOfEachItem or displayName).
3) Please make sure that the identifier(here uniqueIdOfEachItem) for each item in the store is unique, if its not unique then combo box will not work, throwing some error similar to what you have mentioned.
这篇关于组合框和值相冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!