forum

Home / DeveloperSection / Forums / Sencha Touch / ExtJs show XTemplate only if array node contains items

Sencha Touch / ExtJs show XTemplate only if array node contains items

Anonymous User 3761 03-Jun-2013
Hi Developers,

How can I show a an XTemplate only if the data array has items at a certain node?

For example below, I only want to show my template for "items." (show day 28's "items" and show nothing for day 27)

Currently it creates a <p> tag for all items in the array, which what I don't want...

        itemTpl     :    new Ext.XTemplate(
                '<tpl for="items">'+
                  '<p>{classname} {typename}</p>'+
                '</tpl>'
        ),

Data from the server:

{
  day:27,
  iscurrentmonth:false,
  issunday:false,
  date:"2013-05-27",
  schedulesection:{
     id:46694897,
     markingperiodid:15156,
     name:"Sunday",
     number:0
  },
  announcements:[
  ],
  items:[
  ]
},
 {
  day:28,
  iscurrentmonth:false,
  issunday:false,
  date:"2013-05-28",
  schedulesection:{
     id:46695811,
     markingperiodid:15156,
     name:"Monday",
     number:1
  },
  announcements:[
  ],
  items:[
     {
        id:134513,
        title:"Subject",
        typeid:3,
        typename:"Essay",
        author:"Bryan Fisher",
        classname:"English 9A",
        classid:344499,
        courseid:60555
     },
     {
        id:134485,
        title:"Subject",
        typeid:3,
        typename:"Essay",
        author:"Bryan Fisher",
        classname:"English 10",
        classid:344500,
        courseid:60555
     }
  ]
 }

Much thanks for your positive response.  

Updated on 03-Jun-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By