View Full Version : Access to XTemplate parent when nested?

1 Apr 2011, 8:25 AM
How can I access a parent when I am nested?

'<tpl if="contentType == \'DayPlanner\'">',
'parent id works right here: {parent.id}',
'<tpl for="day">',
'parent id fails here, how do we access it? {parent.id}',
// tried {parent.parent.id}, that doesn't work.

Any tips or workarounds?

1 Apr 2011, 9:37 AM
I did search on this topic before I posted, but not until after I posted did I see Condor's answer to a similar post. http://www.sencha.com/forum/showthread.php?116717-Xtemplate-issue-How-to-access-a-a-top-level-property-from-within-two-nested-loops

The magic is the secret command:

'<tpl exec="values.parent = parent;"></tpl>'

This exec REALLY ought to be mentioned in the XTemplate documentation.

27 Dec 2012, 2:23 AM
You saved my day !

+1 for the documentation update ...