在我尝试加载到 RoundRectList 的数组中,我想要的标签数据(全名)被分成数组中的 3 个项目(“FullName”+“MiddleName”+“LastName”)。当我构建 JsonRestStore 时,我不能简单地编写
var store = new JsonRestStore({ target: url, allowNoTrailingSlash: 1, labelAttribute: "FullName" + "MiddleName" + "LastName" });
因为这样它就会显示为正在寻找名为“FullNameMiddleNameLastName”的项目。如果我将这三个选项设置为变量并将其作为 labelAttribute 传入,则具有相同的效果。
有什么方法可以在 JsonRestStore 的 labelAttribute 中执行我想要的操作吗?
最佳答案
我不确定您是指 dojo/store/JsonRest
还是 dojox/data/JsonRestStore
,但幸运的是,我相信它们都支持这一点:
var store = new JsonRestStore({
target: url,
getLabel: function(i) {
return i.FullName + " " + i.MiddleName + " " + i.LastName;
}
});
我只能在 dojox 文档中找到它:http://dojotoolkit.org/api/1.8/dojox/data/JsonRestStore#getLabel
关于javascript - JsonRestStore 中的 labelAttribute 由数组中的多个项目构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13845091/