views:

22

answers:

1

The title says it all. Is it possible to make another dojo.data.ItemFileWriteStore out of the properties of items from an existing dojo.data.ItemFileWriteStore?

For example, i have a store containing an item with an array as a property. I want to make a new store out of the properties of one of those arrays, like so:

... new dojo.data.ItemFileWriteStore({ data:{items:selectedItem.moreItems} });

Im currently trying to do this, but dojo's magic is getting in the way. Namely, there are __id and __default properties being added to the item i fetch from the first store, and these properties cause the data for the second store to be malformed... how do i get around this?

A: 

Figured it out:

the dojo.data api sticks lots of recursive references to objects persisted inside its stores.

When you want to use parts of these objects in different stores you have to thoroughly scrub away these references. To solve this problem, i recursively took a shallow copy of all the properties of the object in question, excluding any private properties (props begining with '_'). Worked like a charm.

Dfowj