开发者

Accessing property in parentView from childViews

So I'm trying to make a splitview a 开发者_JAVA百科bit more reuseable in my app but I'm stuck right now trying to make the bindings in the two content views easy to setup.

My topLeftView contains a SC.ScrollView which has a SC.ListView as its contentView. I would like to be able to set the contentBinding, selectionBinding, contentValueKey and contentCheckboxKey properties of the ListView when using the splitview and therefor have some properties in the splitview itself which the ListView uses. Does that make any sense?

So here's what I have:

SomeApp.MasterDetailView = SC.SplitView.extend({
...
masterViewControllerContent: 'SomeApp.someController.arrangedObjects',
masterViewControllerSelection: 'SomeApp.someController.selection',
masterViewControllerValueKey: "someKey",
masterViewControllerCheckboxKey: undefined,

topLeftView: SC.ScrollView.design({
   ...
            contentView: SC.ListView.design({
                contentBinding: masterViewControllerContent,
                selectionBinding: masterViewControllerSelection, 
                contentValueKey: masterViewControllerValueKey, 
                contentCheckboxKey: masterViewControllerCheckboxKey, 
        })
    }),

bottomRightView: SomeApp.DetailsView.design({
    ...
})

})

Referring to masterViewControllerContent gives an error but I can't seem to find anyways to go to the scope of the splitView when referring to masterViewControllerContent. Am I solving the problem the wrong way? Any suggestions to how this should/could be done?


Every view has a 'parentView' property. So in the ListView you could bind to

'.parentView.parentView.masterViewControllerContent'

If you are creating a new view (App.MasterDetailView) then setting the content on the master detail, and having the child views bind in to that content is ok.

If you just have a SplitView with a Scroll and a List (i.e. the SplitView is not a special view that you are going to augment), though, I would bind the list directly to its content.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜