【问题标题】:dojo gridx not finding memory store datadojo gridx 找不到内存存储数据
【发布时间】:2015-06-22 20:07:47
【问题描述】:

我正在尝试让 gridx 正常工作。我从硬编码数据开始,稍后将移动到 json 数据数组。当我运行下面的代码时,我得到的只是标题。我在 Grid Playgound 示例之后对代码进行建模。我认为这可能是因为我使用的是 Store() 而不是 Memory()。 但是,当我使用“var store = new Memory({”) 时,我不再得到标题...

花了很多时间在网上搜索,但大多数示例似乎都假设了一些关于 gridx 的预先存在的知识。

这是我的代码:

<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>

任何帮助将不胜感激!

【问题讨论】:

  • 有什么想法吗?这段代码看起来很脆弱,几乎我所做的任何更改都没有输出(我丢失了结构中的标题)。

标签: dojo dojo.gridx


【解决方案1】:

这就是我的工作......

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

ObjectStore 和 Memory 的组合似乎奏效了。

【讨论】:

    【解决方案2】:

    您是否加载了 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">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-21
      • 2017-06-16
      相关资源
      最近更新 更多