0

我正在尝试让 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>

任何帮助将不胜感激!

4

2 回答 2

0

这就是我的工作...

constructor : function(dataIn) {
  this.store = new ObjectStore({  // instance attribute
    objectStore : new Memory({
      data : dataIn
    })
  });
...rest of constructor...  

ObjectStore 和 Memory 的组合似乎有效。

于 2015-08-03T20:29:17.233 回答
0

您是否加载了 Gridx css 文件?我在小提琴中复制了你的代码,它正在工作:http: //jsfiddle.net/5ynqhk2L/2/

我唯一添加的是 Gridx.css。

  <link rel="stylesheet" type="text/css" href="http://oria.github.io/gridx/build/gridx/resources/claro/Gridx.css">
于 2015-09-10T08:04:26.423 回答