Search code examples
extjsxtemplate

ExtJS-- XTemplate using JSON data, show certain values as links


Below is my tpl that uses JSON data. I simply want to check if "Key" == "something", show the corresponding "Value" as a link.

thanks

this.tpl = new Ext.XTemplate(
  '<div class="blah" style="padding-bottom:3px;float:left;">Details</div>',
    '<hr style="clear:left;"/>',
      '<tpl for=".">',
         '<span class="blah"><b>{Key}:</b> {Value}</span>',
        '</tpl>',
      '</div>',
      '<br>'
    );

Solution

  • '<span class="blah"><b>{Key}:</b>',
         '<tpl if="Key==\'something\'"><p><a herf="#">{Value}</a></tpl>',
         '<tpl if="Key!=\'something\'"><p>{Value}</tpl>',
     '</span>',
    

    Test in extjs3.3