---
title: "Sencha Touch / ExtJs show XTemplate only if array node contains items"  
description: "Sencha Touch / ExtJs show XTemplate only if array node contains items"  
author: "Anonymous User"  
published: 2013-06-03  
updated: 2013-06-03  
canonical: https://www.mindstick.com/forum/968/sencha-touch-extjs-show-xtemplate-only-if-array-node-contains-items  
category: "sencha touch"  
tags: ["sencha touch"]  
reading_time: 2 minutes  

---

# Sencha Touch / ExtJs show XTemplate only if array node contains items

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs),\
How can I show a an **XTemplate** only if the data [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) has [items](https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios) at a certain [node](https://www.mindstick.com/forum/161418/what-is-node-js-and-how-does-it-work)?\
For example below, I only want to show my [template](https://www.mindstick.com/blog/282/creating-custom-template-in-joomla) 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](https://www.mindstick.com/forum/12652/how-to-set-typename-in-the-constructor-of-new-sqlparameter)}</p>'+ '</tpl>' ),\
**[Data from the server](https://www.mindstick.com/forum/156656/fetch-the-json-data-from-the-server-through-jquery):**\

```
{  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.

## Replies

### Reply by AVADHESH PATEL

Hi Ankita,\
Try as following,\

```
itemTpl: [    '<tpl for="items">',        '<tpl if="values.classname">',            '<p>{classname} {typename}</p>',        '</tpl>',    '</tpl>',].join('')
```

\
Hope it helpful for you.


---

Original Source: https://www.mindstick.com/forum/968/sencha-touch-extjs-show-xtemplate-only-if-array-node-contains-items

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
