0

I'm having some problems getting the Dojo Grid widget to work.

The grid itself is added declaratively:

<table data-dojo-type="dojox.grid.DataGrid" data-dojo-attach-point="relationshipsGrid"></table>

Next, I'm trying to bind the grid to a Memory data store:

var relationships = [
                  { id: 1, market: "SE", entity: "An object" },
                  { id: 2, market: "SE", entity: "Another object" },
                  { id: 3, market: "SE", entity: "Yet another object" }
                ];

                var store = new Memory({ data: relationships });

                var layout = [[
                  { 'name': 'ID', 'field': 'id', 'width': '10px' },
                  { 'name': 'Market', 'field': 'market', 'width': '30px' },
                  { 'name': 'Entity', 'field': 'entity', 'width': '100px' }
                ]];

                this.relationshipsGrid.structure = layout;
                this.relationshipsGrid.store = store;
                this.relationshipsGrid.startup();

However, all I end up with is an empty, 0-height grid. If I explicitly set a height to it I just get an empty grayish area. There is a lot of Dojo markup rendered, but without any items from my store.

I'm sure I'm overlooking something trivial (hopefully), but any help is greatly appreciated! :)

1 Answer 1

0

dojox/grid does not support the dojo/store API directly, and is also no longer maintained.

You have a few options:

  • Wrap a dojo/store with dojo/data/ObjectStore to convert it to the old dojo/data API that dojox/grid understands
  • Use a dojo/data store directly (not recommended, since it's been deprecated for years)
  • Use a more modern grid package like dgrid (0.3.x supports dojo/store; 0.4.x supports dstore which aims to be the next generation of dojo stores)
3
  • Thanks for your help! Was hoping there would be an OOTB component in dijit or dojox. :/ A full-blown data grid is actually a bit overkill in this case, do you know if there's any standard Dojo widget which supports data binding and basically renders a table? I.e. without all the bells and whistles of a data grid?
    – Ted Nyberg
    Commented Feb 15, 2015 at 0:03
  • 1
    I'm not aware of any store-based table components in DTK off the top of my head, but you'd basically just need to do a store.query().forEach(...) and use dojo/dom-construct to create/place table rows/cells within the callback. RE "OOTB": The "kitchen sink" approach of dojox has turned out not to work very well over the years, so separate packages is generally the direction we're headed (but they could potentially be bundled together as a single download in the future). dgrid is typically a go-to component for projects I work on now. Commented Feb 15, 2015 at 1:45
  • Thanks for your help, appreciate it! I think I'll give dgrid a try, otherwise I'll just databind a <table> using Knockout or Angular. Cheers!
    – Ted Nyberg
    Commented Feb 16, 2015 at 12:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.