Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#5396 closed defect (invalid) breaks when items contain objects

Reported by: guest Owned by: Jared Jurkiewicz
Priority: high Milestone:
Component: Data Version: 1.0
Keywords: ItemFileReadStore Cc: [email protected]
Blocked By: Blocking:


ItemFileReadStore? breaks when input data contains objects inside items, e.g.:

items: [
  { name:'Africa', type:'continent', breaker: {} }

The store takes the inner object as another item and adds it to the _arrayOfAllItems.

To reproduce this just add the breaker from above to the countries.json on test page: Grid using Dojo.Data.

This has been discussed at the forums: Getting grid to work with and Dojo Grid+CakePHP.

Change History (4)

comment:1 Changed 13 years ago by Jared Jurkiewicz

Resolution: invalid
Status: newclosed

This isn't a defect. That is intentional behavior of ItemFile?*Store. Properties of an item that are an object that are object types are treated as items and created as items.

This is so that ItemFile?*Store can handle hierarchical structures of items for trees without references. This is also demonstrated in the dojo book at:

Second example data format shows hierarchical constructs of items using objects instead of references

comment:2 Changed 13 years ago by Jared Jurkiewicz

There is a way to do child objects so that they're not converted to a generic 'item'. Use the typeMap parameter and define a syntax for your custom objects to be de-serialized. That way you can then deserialize that object as just raw JS object type and not an item, in such cases. There is an example of using the build in typeMap code for Date in the documentation.

For example, if you wanted to do a raw object that doesn't get converted to item format, you could do something like (pseudocode'ish):

dojo.declare("foo.ObjectWrapper?", Object, {constructor: function(params){dojo.mixin(this, params};}); typeMap:{'foo.ObjectWrapper?': {

type: foo.ObjectWrapper?, deserialize: function(value){

return new foo.ObjectWrapper?(value);


} var dataStore = new{url: "some/url", typeMap: typeMap});

And then in your data set do something like: items: [

{ name:'Africa', type:'continent', breaker: {_type: 'foo.ObjectWrapper?' _value:{}} }


And You should get the behavior you expect, I believe. I haven't tried it, but I believe it should do what you wanted here.

comment:3 Changed 13 years ago by Adam Peller

Milestone: 1.0.3

comment:4 Changed 13 years ago by guest

Filed a bug about the original problem for dojox grid: Grid content doesn't render when store items contain objects

Note: See TracTickets for help on using tickets.