0

I'm trying to figure out how I can retrieve a set of objects from the datastore, pass the SC.ManyArray to a controller then have a view iterate over the arrangedObjects to create custom SC.Views that I'd like to be able to append to other various views already appended to the DOM.

All I can find are examples of how to do this using the SproutCore pre built ListView/CollectionView/TableView etc. But I need these generated custom views to be appended to other views.

On another related but separate issue, when I inspect the object returned from the call to MyApp.store.find() the dataHashes property doesn't include all of my fixtures that I've included. I'm not sure if it's because I haven't created a view to call the data yet though because if I use the console I can return all the fixtures.

I'll also add that the data I'm retrieving is coming from a toMany relation from the master record. I'm retrieving the SC.ManyArray using a binding to the content of the SC.ArrayController with the path MyApp.masterModel.relationProperty.

Edit: I meant to say MyApp.masterModelController.relationProperty

Any insight would be great. I've been trying to figure this out for 2 days now and there doesn't seem to be any information found with google or the SproutCore docs.

4

1 回答 1

0

我已经想通了...

我最终做的是创建一个SC.CollectionView并将内容绑定到SC.ArrayController用于管理数据收集的内容。当我将此集合视图添加到childViews数组中时,它会自动获取与模型 toMany 关系相关的固定装置,并创建我创建的自定义视图并将其设置为exampleViewon,SC.CollectionView并且使用这些对象更新了 storesdataHashes属性。

在我创建的用于显示对象的自定义视图上,我覆盖了该didAppendToDocument方法,获取了容器视图的路径,以便将这些视图附加到并用于appendChild附加创建的自定义视图。

最后一件事是隐藏,SC.CollectionView所以我只是将layout属性设置为{top:-1000,left:-1000,width:0,height:0}.

我不是 100% 确定这是解决此问题的最佳方法,但它确实有效(至少对我而言)。

我很想听听任何其他建议来实现这一点。

于 2012-09-02T01:49:26.883 回答