Results 1 to 3 of 3

Thread: Get Parent Values in an XTemplate Conditional Statement

  1. #1
    Sencha User
    Join Date
    Apr 2007
    Posts
    138
    Answers
    1

    Default Get Parent Values in an XTemplate Conditional Statement

    I have some Ajax data in a store that resembles this format:
    Code:
    {
       "courses":[
          {
             "courseID":"1",
             "courseName":"Math",
             "tests":[
                {
                   "testID":"1",
                   "testName":"Ye Old Math Test",
                   "courseID":"1",
                   "courseName":"Math",
                   "testType":"Test"
    ...and so on. I've got a DataView and I'm trying to run through the tests array, displaying only the tests with the same courseID as the course in which it is located. Here's my DataView tpl, which isn't working:

    Code:
    <tpl for="tests">
        <tpl if="courseID == parent.courseID"> //<-- This is not working
        <div>Test Name: {testName} ({courseID}{parent.courseID})</div>
        </tpl>
    </tpl>
    Is there a way to create a conditional statement that compares a value with a parent value?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,451
    Answers
    3997

    Default

    This works for me:

    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Apr 2007
    Posts
    138
    Answers
    1

    Default

    Mitchell,

    Thanks for the solution, and it looks great. The problem is that I can't seem to get it implemented in the scope of using a Store and associated Models. Perhaps you can take a look at this Fiddle?


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •