我正在尝试使用gridx。我从硬编码数据开始,稍后将转移到json数据数组。当我运行下面的代码时,我得到的只是标题。我在Grid Playgound样本之后对代码进行了建模。我认为这可能是因为我使用Store()而不是Memory()。 但是,当我使用“var store = new Memory({”时,我不再得到标题......
花了很多时间在网上搜索,但大多数例子似乎都假设了一些预先存在的gridx知识。
这是我的代码: <%@ page language =“java” contentType =“text / html; charset = ISO-8859-1”pageEncoding =“ISO-8859-1”%>
<title>testSelect</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript"
data-dojo-config="isDebug: true, async: true, parseOnLoad: true"
src="dojo/dojo/dojo.js"></script>
<script type="text/javascript">
require(
[ "dojo", "dojo/parser" ],
// Callback function, invoked on dependencies evaluation results
function(dojo) {
dojo.ready(function() {
});
});
</script>
<script type="text/javascript">
require([
"gridx/Grid",
"gridx/core/model/cache/Sync",
"gridx/modules/VirtualVScroller",
"gridx/modules/ColumnResizer",
"gridx/modules/extendedSelect/Row",
"gridx/modules/SingleSort",
"dojo/store/Memory",
"dojo/domReady!"
], function(Grid, Cache,
VirtualVScroller, ColumnResizer, SelectRow,
SingleSort, Store){
//Create store here...
//var store = new Store(...);
var store = new Store({
data: [
{id: "1", name:"name1", genre:"genre1", composer:"composer1", year:"1952"},
{id: "2", name:"name2", genre:"genre2", composer:"composer2", year:"1953"}
]
});
var grid = new Grid({
store: store,
cacheClass: Cache,
structure: [
{ id: "column_1", field: "name", name: "Name", width: "50%" },
{ id: "column_2", field: "genre", name: "Genre" },
{ id: "column_3", field: "composer", name: "Composer" },
{ id: "column_4", field: "year", name: "Year" }
],
selectRowTriggerOnCell: true,
modules: [
VirtualVScroller,
ColumnResizer,
SelectRow,
SingleSort,
]
});
grid.placeAt("gridContainer");
grid.startup();
});
</script>
</head>
<body class="claro">
<div id="gridContainer"></div>
</body>
</html>
非常感谢任何帮助!
答案 0 :(得分:0)
这就是我的工作......
constructor : function(dataIn) {
this.store = new ObjectStore({ // instance attribute
objectStore : new Memory({
data : dataIn
})
});
...rest of constructor...
ObjectStore和Memory的组合似乎有效。