Results 1 to 2 of 2

Thread: Adding condition to a tpl

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    9
    Vote Rating
    0
      0  

    Default 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
    Answers
    16
    Vote Rating
    14
      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>

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
  •