-
6 Oct 2011 8:17 PM #1
Answered: Empty Xtemplate?
Answered: Empty Xtemplate?
Hi,
I have a XTemplate as below:
if there are no objects/an empty array is being passed in.. how can i have an alternative display of "no comments are posted" ??commentInfo = new Ext.XTemplate(
'<tpl for=".">',
'{name} at {timestamp} <br />',
'{comment}',
'</tpl>'
);
please advise!
thanks!
-
Best Answer Posted by bclinton
xcount only works within the loop. Try this:
Note: This works in ExtJS and I assume it will work in Touch but I haven't tested it .Code:'<tpl if="values.length <= 0">', 'no comments are posted', '</tpl>',
-
6 Oct 2011 10:00 PM #2
khangwei,
You could use a data view, which lets you define an "emptyText" property, but if you want to use an XTemplate object directly without any of that extra complexity, I think the solution in your case is to use the xcount value combined with some template logic. For instance:
Perhaps there is a better way, but this should work fine.Code:commentInfo = new Ext.XTemplate( '<tpl for=".">', '{name} at {timestamp} <br />', '{comment}', '</tpl>', '<tpl if="xcount == 0">', 'no comments are posted', '</tpl>' );
-
19 Oct 2011 1:34 PM #3
Hi,
I did this but it is still not working,
any idea why?
Thank you!
Code:commentInfo = new Ext.XTemplate( '<tpl if="xcount == 0">', 'No comments are posted', '</tpl>', '<tpl if="xcount > 0">', '<tpl for=".">', '{name} at {timestamp} <br />', '{comment}', '</tpl>' );
-
2 Nov 2011 10:06 AM #4
-
17 Nov 2011 8:24 AM #5
Hi all..
Still no solutions for this, can anyone help me?
Thank you!
-
28 Nov 2011 2:21 PM #6
xcount only works within the loop. Try this:
Note: This works in ExtJS and I assume it will work in Touch but I haven't tested it .Code:'<tpl if="values.length <= 0">', 'no comments are posted', '</tpl>',Try the Sencha Learning Center
-
13 Dec 2011 2:27 PM #7


Reply With Quote