Search code examples
sproutcore

How should I binding value to make the labelView in CustomItemView show the text info in the listController?


I try to design a custom view inside a listView. The code looks like the following:

Myapp.listView=SC.ScrollView.design({
  layout: { centerX: 0, width:100, top: 70, bottom:36},
  contentView: SC.ListView.design({
    contentBinding: SC.Binding.oneWay('Myapp.listController'),
    rowHeight: 36,
    exampleView:Myapp.CustomItemView.design({

         })

  })
});



MyApp.CustomItemView = SC.View.design({
          childViews:['imageView','labelView'],

          imageView: ....,
          labelView:SC.LabelView.design({

   })

});

My question is: How should I binding value to make the labelView in CustomItemView show the text info in the listController?


Solution

  • Like Ramesh say, your customItemView should be like this:

    MyApp.CustomItemView = SC.View.design({
      childViews:['imageView','labelView'],
    
      imageView: ...
      labelView: SC.LabelView.design({
        valueBinding: ".parentView.content.textInfo"
      })