PDA

View Full Version : Update groupTextTpl on GroupBy



shinkenno
17 Jan 2011, 7:15 AM
Hello everybody,

I am using a grouping grid and I am wondering if it is possible to dynamically update/modify the groupTextTpl when grouping the grid by another field (with GroupBy) ?
Thank you for your answers.

Condor
17 Jan 2011, 7:36 AM
No, you can't update groupTextTpl.

Two options:
1. Create a groupTextTpl with <tpl if="..."> statements to have it render differently for different group fields.
2. Replace the startGroup template before the grid is refreshed.

shinkenno
17 Jan 2011, 7:59 AM
The 1st solution is working perfectly:


groupTextTpl: '<tpl if="groupId.indexOf(\'currenttime\') != -1">{text}</tpl>' +
'<tpl if="groupId.indexOf(\'src_name\') != -1">{text} ({[values.rs.length]} {[values.rs.length > 1 ? "scans" : "scan"]})</tpl>' +
'<tpl if="groupId.indexOf(\'duration\') != -1">{text} seconds</tpl>',

Thanks Condor ! Quick and efficient, as usual !

shinkenno
17 Jan 2011, 8:38 AM
Another question: Is there a way to put the group title on the left and the group summary (number of items) on the right side of the group header line ?
Thanks!

shinkenno
17 Jan 2011, 9:12 AM
Ok. Found it myself...I just added a div with the right css rule...Easier than what I thought:



groupTextTpl: '<tpl if="groupId.indexOf(\'src_name\') != -1">{text} <div style="float:right;">({[values.rs.length]} {[values.rs.length > 1 ? "scans" : "scan"]})</div></tpl>',