dojo gridx not finding memory store data

520 views Asked by At

I am attempting to get a gridx working. I am starting with hardcoded data and will be moving to an array of json data later. When I run the code below, all I am getting is the headings. I was modeling the code after the Grid Playgound samples. I thought it might be because I was using Store() instead of Memory(). However, when I use "var store = new Memory({", I no longer get the headings...

Spent a lot of time searching the web, but most of the examples seem to assume quite a bit of pre-existing knowledge for gridx.

Here is my code: <%@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>

Any help would be greatly appreciated!

2

There are 2 answers

0
Jay Witherspoon On

This is what I got working...

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

the combination of ObjectStore and Memory seemed to work.

0
gotcha On

Did you load the Gridx css file? I copied your code in a fiddle and it's working: http://jsfiddle.net/5ynqhk2L/2/

The only thing I added is Gridx.css.

  <link rel="stylesheet" type="text/css" href="http://oria.github.io/gridx/build/gridx/resources/claro/Gridx.css">