1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    9
    Vote Rating
    0
    thiszparveen is on a distinguished road

      0  

    Default Unanswered: Adding condition to a tpl

    Unanswered: Adding condition to a tpl


    Hi,

    My requirement is to print "No" if the value of "test" is empty string. otherwise i need to print the value of test as it is.
    rently it is printing blank if the value of test is empty string. I wanted to print "No" instead.
    Cur
    How can I add that condition in tpl. Could some one help me out.

    var tpl = new Ext.XTemplate(
    "<table><tr><td>Test</td></tr><tr><td>{test}</td></tr></table>"
    );

    Thanks,

  2. #2
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Vote Rating
    13
    Answers
    16
    flanders will become famous soon enough

      0  

    Default


    Here is the documentation for XTemplate: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.XTemplate

    This should do the trick:

    Code:
    <tpl if='test == \"\"'>No<tpl else>{test}</tpl>

Thread Participants: 1

Tags for this Thread