我正在尝试让 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>
任何帮助将不胜感激!