Results 1 to 6 of 6

Thread: [SOLVED] : if else in Ext.XTemplate

  1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    418
    Vote Rating
    0
      0  

    Default [SOLVED] : if else in Ext.XTemplate

    Hi,

    I am trying to show different thumbnail for video and images.

    Now there is some syntax error. Can someone help with this?.

    Thanks.

    Code:
     myexpander= new Ext.grid.RowExpander({
    tpl: new Ext.XTemplate(
    '<p>',															'<tpl if="mediatype==image">',
    '<p><img src="'+Ext.webhost+'/media/{property}/images/{medianame_file}" width="100" height="75"  ></p>',
    '</tpl>',
    '<tpl if="mediatype==video">',
    '<p><img src="'+Ext.webhost+'/media/video.jpg" width="100" height="75"  ></p>',
    '</tpl>',
    '</p>'
    )
    });
    Image and video are strings. mediatype is column value

    I think it is problem of comparing to string. It is assuming video and image as column.

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,626
    Vote Rating
    56
      0  

    Default

    It needs quotes, otherwise it's gonig to compare it to the image property rather than the string "image".
    Longtime Sencha geek. Outspoken advocate of pure Javascript Views. Posts my own opinions.

  3. #3
    Ext User
    Join Date
    Apr 2008
    Posts
    418
    Vote Rating
    0
      0  

    Default

    Still nothing!. No error though. Just blank except the filename text i added last to indicate everything works except template if else.

    Code:
    myexpander= new Ext.grid.RowExpander({
    tpl: new Ext.XTemplate(
    '<p>',
    '<tpl if="mediatype=='+"'image'"+'">',
    '<p><img src="'+Ext.webhost+'/media/{property}/images/{medianame_file}" width="100" height="75"  ></p>',
    '</tpl>',
    '<tpl if="mediatype=='+"'video'"+'">',
    '<p><img src="'+Ext.webhost+'/media/video.jpg" width="100" height="75"  ></p>',
    '</tpl>',
    '</p>',
    '<p>{medianame_file}</p>'
    });

  4. #4
    Ext User
    Join Date
    Apr 2008
    Posts
    418
    Vote Rating
    0
      0  

    Default

    Infact it works. mediatype is combo box. I need to compare with combobox values not the display value.

    Here is the image of my grid.


  5. #5
    Ext User
    Join Date
    Apr 2008
    Posts
    418
    Vote Rating
    0
      0  

    Default

    close this.

  6. #6
    Sencha User
    Join Date
    Feb 2013
    Posts
    1
    Vote Rating
    1
      1  

    Default

    see if these examples help


    '<tpl if="id == \'download\'">...</tpl>',
    "<tpl if='name == \"Don\"'>Hello</tpl>"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •