PDA

View Full Version : Dynamic GroupHeaderTpl



talha06
26 Jul 2012, 5:25 AM
Hello everyone,

I need to change groupHeaderTpl upon to the groupingField value. In my case I group through a boolean field.
How can I do this? I tried some variants but unable to achieve to my goal.
I'll be happy if someone can help me?
Thanks i advance.


groupHeaderTpl: '{name}=="true" ? Shared : Your own'

groupHeaderTpl: '[{name}=="true" ? Shared : Your own]'

talha06
26 Jul 2012, 11:19 AM
Any ideas?? :-?

scottmartin
26 Jul 2012, 2:02 PM
Have a look at the following for function / condition support in templates:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.XTemplate
http://localhost/extjs4/docs/#!/api/Ext.grid.feature.Grouping-cfg-groupHeaderTpl

Scott.

talha06
26 Jul 2012, 10:30 PM
Thanks Scott, I've looked there before too.. So what's wrong here, can you explain me please?


var tpl = new Ext.XTemplate(
'<tpl if="{name} == true">',
'<p>Public Documents</p>',
'</tpl>',
'<tpl else>',
'<p>Your Documents</p>',
'</tpl>'
);

var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
groupHeaderTpl: tpl
});

scottmartin
2 Aug 2012, 1:29 PM
In looking looking at template, I would say you should make the following changes:



var tpl = new Ext.XTemplate(
'<tpl if="name == true">', // {name} used to display vs name to eval
'<p>Public Documents</p>',
'</tpl>',
'<tpl else>',
'<p>Your Documents</p>',
'</tpl>'
);


Scott.

talha06
2 Aug 2012, 4:52 PM
In looking looking at template, I would say you should make the following changes:



var tpl = new Ext.XTemplate(
'<tpl if="name == true">', // {name} used to display vs name to eval
'<p>Public Documents</p>',
'</tpl>',
'<tpl else>',
'<p>Your Documents</p>',
'</tpl>'
);


Scott.
Unfortunately it gives no group header..
37713