---
title: "If- else statement in itemTpl configuration"  
description: "In this blog, I’m explaining how to write the if-else statement in itemTpl configuration of list in sencha touch."  
author: "Sumit Kesarwani"  
published: 2013-06-19  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1338/if-else-statement-in-itemtpl-configuration  
category: "sencha touch"  
tags: ["sencha touch"]  
reading_time: 3 minutes  

---

# If- else statement in itemTpl configuration

In this blog, I’m explaining how to write the if-else statement in itemTpl [configuration](https://www.mindstick.com/articles/13112/setting-up-the-perfect-configuration-for-your-work-computer) of list in [sencha touch](https://www.mindstick.com/blog/619/changing-sencha-touch-app-theme).\

We have the list full of [records](https://www.mindstick.com/forum/34640/how-to-create-a-stored-procedure-for-display-all-records) and want to display such records which specify the given condition.

##### Example

##### Step-1:

First create a [store](https://www.mindstick.com/articles/12379/magento-store-locator-extension-with-google-map) to [populate](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) the list. In my store, there is two [fields](https://answers.mindstick.com/qa/96632/explain-about-relationships-and-look-up-fields-in-ms-access) name and [Boolean](https://www.mindstick.com/forum/160332/how-does-the-boolean-function-work), the name field has different names and Boolean field have two [values](https://www.mindstick.com/forum/159360/how-to-write-sql-query-to-join-comma-separated-values) either [true or false](https://www.mindstick.com/forum/160329/how-can-you-convert-a-value-to-a-boolean-true-or-false-in-javascript).

```
Ext.define('MyApp.store.MyStore', {
    extend: 'Ext.data.Store',
 
    config: {
        data: [
            {
                name: 'Alex Stewart',
                boolean: 'true'
            },
            {
                name: 'Joseph Henry',
                boolean: 'false'
            },
            {
                name: 'Steve Smith',
                boolean: 'true'
            },
            {
                name: 'Paul Jones',
                boolean: 'false'
            },
            {
                name: 'Bill Skew',
                boolean: 'true'
            }
        ],
        storeId: 'MyStore',
        fields: [
            {
                name: 'name'
            },
            {
                name: 'boolean'
            }
        ]
    }
});
```

Step-2:

Next create a list and add the store to it. In the itemTpl configuration of list write the if-else statement as shown below:

```
Ext.define('MyApp.view.MyList', {
    extend: 'Ext.dataview.List',
 
    config: {
        store: 'MyStore',
        itemTpl: [
            '<tpl if="boolean == \'true\'">',
            '    <p>{name}</p>',
            '    <tpl else>',
            '                   <p>Boolean is false</p>',
            '</tpl>'
        ]
    }
});
```

[Output](https://www.mindstick.com/interview/34427/explain-the-output-in-angular)

![If- else statement in itemTpl configuration](https://www.mindstick.com/mindstickarticle/7e3fe0fa-60b0-486b-afb1-0f616d8661c9/images/2ae8ff3c-3b14-4970-94e9-661c9e791b67.png)

---

Original Source: https://www.mindstick.com/articles/1338/if-else-statement-in-itemtpl-configuration

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
