1. #1
    Sencha User
    Join Date
    Dec 2013
    Posts
    52
    Vote Rating
    2
    Answers
    1
    JohnJones357 is on a distinguished road

      0  

    Default Unanswered: tpl--having to iterate additional times when using store as opposed to inline data

    Unanswered: tpl--having to iterate additional times when using store as opposed to inline data


    I need an explanation on why I have to iterate multiple times when using a store for my tpl and not when using inline data using "data" property.

    Inside my DataView initComponent:

    Code:
     this.tpl = new Ext.XTemplate(
         '<table border="1" width="100%">',
           // '<tpl for = ".">',
               '<tr>',
                  '<tpl for="COLUMNS">',
                      '<th style="color:white;">{.}</th>',
                  '</tpl>',
               '</tr>',
            // '</tpl>',
            // '<tpl for=".">',
             '<tpl for="ROWS">',
               '<tr>',
                 '<tpl for=".">',
                   '<td align="center" style="background-color:{[this.getHeatColor(values.HEAT)]}">{VAL}</td>',
                 '</tpl>',
               '</tr>',
             '</tpl>',
             //'</tpl>',
         '</table>',
    when using a store, im having to iterate using <tpl for="."> (commented out above) before looping through COLUMNS array and again before looping ROWS array. I wanted to know why I need to iterate twice because both COLUMNS and ROWS are in the same data root.

    When using inline data i can use above tpl as is, with the <tpl for="."> commented out.

    JSON data:

    Code:
    { "data" : {
          "COLUMNS": [
             "Column 1",
             "Column 2",
             "Column 3"
           ],
    
    
          "ROWS": [
             [{"VAL":"R1C1", "HEAT":1}, {"VAL":"R1C2", "HEAT":3}, {"VAL":"R1C3", "HEAT":2}],
             [{"VAL":"R2C1", "HEAT":1}, {"VAL":"R2C2", "HEAT":1}, {"VAL":"R2C3", "HEAT":4}]
           ]
         }
     }

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,993
    Vote Rating
    212
    Answers
    476
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    It may help to see your code demonstrated. Can you share a test case at https://fiddle.sencha.com showing how you're processing each use case?
    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

  3. #3
    Sencha User
    Join Date
    Dec 2013
    Posts
    52
    Vote Rating
    2
    Answers
    1
    JohnJones357 is on a distinguished road

      0  

    Default


    https://fiddle.sencha.com/#fiddle/cb2

    here is the fiddle for the inline data use case. Will post use case using json data from store shortly

  4. #4
    Sencha User
    Join Date
    Dec 2013
    Posts
    52
    Vote Rating
    2
    Answers
    1
    JohnJones357 is on a distinguished road

      0  

    Default


    Here is the fiddle for the use case using a store. However, I am unable to run it because of the following error--
    document[root].slice is not a function. I am only getting this error in fiddle. Its working as expected inside my app.

    https://fiddle.sencha.com/#fiddle/cc9

  5. #5
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,993
    Vote Rating
    212
    Answers
    476
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    The store is expecting to be able to read in unique records and apply the data from those records to the view template.
    For this sort of data I'd use Ext.Ajax.request() to pull the data down and then apply it to the dataview.
    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

Thread Participants: 1