我对filteringSelect和用dojox.data.XmlStore创建的商店有问题。加载元素后,它会显示ID而不是标题(来自displayedValue)。
After the page is loaded - The unexpected result
我该如何解决这个问题呢?有解决办法吗?(也许我只有两只左手…)
HTML文件:
<!DOCTYPE html>
<html >
<head>
<link rel="stylesheet" href="resources/js/dojo/dijit/themes/claro/claro.css">
<script>dojoConfig = {parseOnLoad: true}</script>
<script src='resources/js/dojo/dojo/dojo.js'></script>
<script>
dojo.require("dojox.data.XmlStore");
var store = new dojox.data.XmlStore({url: "test.xml", rootItem: "states", keyAttribute:"id", label:"name"});
require([
"dojo/store/Memory", "dijit/form/FilteringSelect", "dojo/domReady!"
], function(Memory, FilteringSelect){
var filteringSelect = new FilteringSelect({
id: "stateSelect",
name: "state",
displayedValue : "test",
store: store,
searchAttr: "name",
labelAttr:'name',
labelType: "text"
}, "stateSelect").startup();
});
</script>
</head>
<body class="claro">
<input id="stateSelect">
</body>
</html>"text.xml":
<?xml version="1.0" encoding="UTF-8"?>
<states>
<state>
<id>3</id>
<name>important</name>
</state>
<state>
<id>4</id>
<name>also important</name>
</state>
<state>
<id>5</id>
<name>test</name>
</state>
<state>
<id>8</id>
<name>scumm</name>
</state>
</states>发布于 2017-01-09 19:18:08
看起来你的rootItem是问题的原因。您将rootItem指定为根文档节点,但是rootItem用于指定您的核心项(要显示的项)
如果未提供rootItem,则XmlStore假定文档的根元素下的标记是根项目。
所以在你的例子中状态应该是“rootItem”insteadOf "state“
https://stackoverflow.com/questions/41504216
复制相似问题