sproutcoresproutcore-viewssproutcore-controllers

How to push my Records into SC.ArrayController content?


I am trying to get my sample data (records created from fixtures) into my SC.ListView. I know the records are built properly because I am able to get particular data by finding it by its primaryKey.

The SC.ListView is pulling its content via contentBinding: 'MyApp.thisController.arrangedObjects' from this SC.ArrayController:

MyApp.thisController = SC.ArrayController.create(SC.SelectionSupport, {
    allowsMultipleSelection: NO,
    content: MyApp.store.find(MyApp.MyRecordType)
});

To init the store I use the function from the official guide:

store: SC.Store.create().from(SC.Record.fixtures)

How do I set my content property in the controller right to import the SC.RecordArray?


Solution

  • this will only work if your store is created before your controller. Try doing

    MyApp.thisController.set('content', MyApp.store.find(....));

    after the app loads, in the console. If that works, you need to query the store after your app initializes.