Results 1 to 2 of 2

Thread: XTemplate TPL IF not working :(

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    Mumbai, India
    Posts
    120
    Answers
    11
    Vote Rating
    4
      1  

    Default Unanswered: XTemplate TPL IF not working :(

    Hi,
    So I know that this seems like a bit of a noob question but its really really not working !! I've tried everything.

    My XTemplate Code
    Code:
    remtable = new Ext.XTemplate(
    "<tpl if='status ==  1'>",
          "<table border=0><tr><td><font size=4><b>{time}</b></font><br><font size=3 color='gray'>",
    
    "<tpl if='valid == 1'>Valid Profile", "<tpl else>Verify Profile", "</tpl>",
    "</font></td>", "<td align='right'> <img id='{id}' align='right' src='resources/images/start.png' height=30 onclick=start('{id}')></td></tr></table>", "</tpl>" );
    My Data Passed :
    Code:
    myData = [
    {
    id : 1, status : 1, valid : 1
    },{
    id : 2, status : 1, valid : 0
    }]
    I'm passing this XTemplate to the list I have in my panel, the template in the list should change depending on the value of "valid" passed to it. But my list doesnt change !! The list tpl goes directly in the "else" loop and displays "Verify Profile" even if the valid:1 is set

    What am I doing wrong ???

    **pulling her hair out**
    Sasha

  2. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124
    Vote Rating
    90
      0  

    Default

    Hi,

    try following code:

    Code:
    Ext.create('Ext.List', {
        fullscreen: true,
        itemTpl:new Ext.XTemplate( "<tpl if='status ==  1'>",
          "<table border=0><tr><td><font size=4><b>{time}</b></font><br><font size=3 color='gray'>",
               "<tpl if='valid ==  1'>Valid Profile",
               "<tpl else>Verify Profile",
               "</tpl>",
               "</font></td>",
             "<td align='right'> <img id='{id}' align='right' src='resources/images/start.png' height=30  onclick=start('{id}')></td></tr></table>",
            "</tpl>"
                                  )
        , data: [
              {
                  id : 1,
                  status : 1,
                  valid : 1
               },{
                    id : 2, 
                    status : 1, 
                    valid : 1
              }]
    });

    Output:

    tpl.png
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

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
  •