PDA

View Full Version : XTemplate container component



hpet
18 Mar 2014, 11:59 AM
I would like to use one XTemplate in multiple components with minor difference - how could I determine in which component template runs? ...like if (component1) then show this, else show that.

scottmartin
18 Mar 2014, 2:57 PM
You can create templates and assign them as needed .. perhaps I do not understand ?

var tplOne = new Ext.XTemplate(..)

tpl: tplOne,

tpl: (myVar = true) ? tplOne : tplTwo,

hpet
18 Mar 2014, 10:56 PM
Hi Martin,

Sorry, I will try to explain again.
I have one XTemplate that I want to use on a two different places (containers).
Basicly these two containers show the same data, but I would like to show it with a minor visual difference - therefore I need to somehow determine, inside XTemplate, which container I am overwriting.
Right now the only idea I have is to push some "marker" into the data passed to the "container.update(data + marker)" call. Or is there some other way?

Example:


var myTemplate =
new XTemplate(
...
if overwriting container 1 then this style
if overwriting container 2 then that style
...
);

...
{
xtype: "container",
id: "container1",
tpl: myTemplate
}, ...

{
xtype: "container",
id: "container2",
tpl: myTemplate
}, ...