-
16 Sep 2008 7:27 AM #1
[SOLVED] : if else in Ext.XTemplate
[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.
Image and video are strings. mediatype is column valueCode: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>' ) });
I think it is problem of comparing to string. It is assuming video and image as column.
-
16 Sep 2008 7:51 AM #2
It needs quotes, otherwise it's gonig to compare it to the image property rather than the string "image".
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
16 Sep 2008 8:28 AM #3
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>' });
-
16 Sep 2008 8:35 AM #4
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.

-
16 Sep 2008 8:39 AM #5
-
12 Feb 2013 7:24 AM #6
see if these examples help
'<tpl if="id == \'download\'">...</tpl>',
"<tpl if='name == \"Don\"'>Hello</tpl>"


Reply With Quote