jeudi 29 janvier 2015

Getting Record Sub-Data

I have a dataview that displays records from a nested store. When I tap on the dataview item, I can access the top level data from the store, but I can't seem to get the nested sub-level data.

My store data is structured as follows:



Code:



courses
|
|_ tests
|
|_ questions
|
|_ answers
|
|_ response

The following Fiddle (below) should help illustrate my problem.


  1. Once the Fiddle is loaded, tap on the 'Archives' tab at the bottom of the screen.

  2. Tap on one of the data items. The top level data (courses) is loading, but I also need to access the sub-level data (tests), and even the next level (questions), and so on.




You can see in the 'mainPanel' controller (onArchivesTabDataviewItemTap) where I have attempted to get the data using the index of the record, but since the top level record is a singular item, it always comes back as 0. I'm thinking that if I can get the index of the tapped item, I can sort down to the sub level using the following code:

Code:



var tests = record.tests();
console.log(record.data.tests[index].testName);

I haven't had any luck getting the tapped item's index, however. Also I may be completely off base with my assumption, so any help accessing the sub-level data would be appreciated.



Getting Record Sub-Data

Aucun commentaire:

Enregistrer un commentaire