开发者

Inject properties into itemrenderer

Is it a bad idea to inject data into an itemrenderer. The reason I ask this is because the state of each item is dependent on different changing data sources. So the original data is used to just display a new item, but there could 开发者_Go百科be two to three other data collections that would be needed to determine the item's behavior. Is there a better way to do this? Should I be creating a custom DataGroup with the other data sources as properties on this custom container and then reference the data sources from the itemrenderer to the parent?

Also, I'm using swiz if this matters or helps at all.


Indeed, it's generally not a good idea, it's much better to set the data property of the renderer, and just make sure that the data contains everything the renderer needs.

If the renderer needs information from other data collections, just set the item's data before assigning it to renderer.

The way, I see it should be like that:

Controller
- Data collection 1
- Data collection 2
- Data collection 3

First, the controller gathers data from the three data collection, and creates some data D based on them

Finally the controller assigns this data D to the renderer. That way the renderer has no dependency to other external data collection.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜