开发者

Can you make a dojo.data store from properties of another dojo.data store?

开发者 https://www.devze.com 2023-01-06 12:47 出处:网络
Is it possible to make another dojo.data.ItemFileWriteStore out of the properties of items from an existing dojo.data.ItemFileWriteStore?

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 ad开发者_StackOverflow社区ded 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消