Dojo OnDemandGrid won't display data

421 Views Asked by At

I'm using arcgis javascript api 3.19 which includes dojo. I'm trying to display some data in a grid and edit it. Right now, the data won't display in the grid.

I'm using the tutorial to learn how to use this grid, [http://dgrid.io/js/dgrid/demos/laboratory/][http://dgrid.io/js/dgrid/demos/laboratory/]

I've embedded their sample code in my widget and it doesn't work.
(Rather than include my whole widget, I'll just show the sample code.) It doesn't find the dgrid/Editor, but it can find dgrid/editor. The grid header and an empty box for the data shows up, but no data.

require([
    'dojo/_base/declare',
    'dstore/Memory',
    'dstore/Trackable',
    'dgrid/OnDemandGrid',
    'dgrid/Keyboard',
    'dgrid/CellSelection',
    'dgrid/Editor'   // I have to use dgrid/editor for this to be found
], function (declare, Memory, Trackable, OnDemandGrid, Keyboard, CellSelection, Editor) {
    var store = new (declare([Memory, Trackable]))({
        data: createData()
    });

    // Instantiate grid
    var grid = new (declare([OnDemandGrid, Keyboard, CellSelection, Editor]))({
        collection: store,
        columns: {
            First_Name: {
                label: 'First Name',
                editor: 'text'
            },
            Last_Name: {
                label: 'Last Name'
            }
        }
    }, 'grid');

    grid.startup();

    function createData() {
        var data = [];
        var column;
        var i;
        var item;

        for (i = 0; i < 50; i++) {
            item = {};
            for (column in { First_Name: 1, Last_Name: 1 }) {
                item.id = i;
                item[column] = column + '_' + (i + 1);
            }
            data.push(item);
        }

        return data;
    }
});
1

There are 1 best solutions below

0
On

Ok, I found the answer.

Esri has two directories in their javascript api, dgrid and dgrid1. And the files in them are largely the same (by filename at least)

Apparently the "correct" classes are in dgrid1, not dgrid.

I suppose there might be a good reason for putting the code in a differently named directory than the documentation, but from where I'm sitting, not knowing that reason, I can only say "Thanks for letting me beat my head against a wall for two days on this. Thanks so very much."