PDA

View Full Version : Is it possible not to display the group header?



ninoguba
16 Jul 2009, 9:32 PM
Is it possible not to display the group header? With group header I meant the row wherein the clickable + image appears along with configured header and rendered group field value.

I need it NOT to display if in that group there is only one record. However if a group has more than one record then it displays the group header as it normally would.

I've searched the forums and didn't find anything. I hope it is possible and if someone can show me how I can accomplish this, that would be great!

Thanks,

Lukman
16 Jul 2009, 10:29 PM
Group? What group? Button group? Checkbox group? Radio button group? Tab group? Be a little more specific, will ya? A sample code will help a lot in getting a good response from people.

ninoguba
16 Jul 2009, 10:45 PM
Group? What group? Button group? Checkbox group? Radio button group? Tab group? Be a little more specific, will ya? A sample code will help a lot in getting a good response from people.

Sorry for not being more specific. I meant Record group within a GridPanel that uses the GroupingView.

Anyway, I not sure if this is the proper way but I managed to accomplish this by modifying the following line of code in ext-all-debug.js:



'<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div class="x-grid-group-title">', this.groupTextTpl ,'</div></div>',


to the following:



'<div id="{groupId}-hd" class="x-grid-group-hd" style="{[values.rs.length > 1 ? "" : "display:none;"]}"><div class="x-grid-group-title">', this.groupTextTpl ,'</div></div>',


and that did the trick. If anybody has suggestions on how to properly implement this, maybe through an extension or a plugin, i'm sure that will help other people looking for this group header customization.

Thanks!

makana
16 Jul 2009, 11:25 PM
That's a good solution, but I would never edit the ext-all-debug.js or ext-all.js.
Either you override the initTemplates-method of Ext.grid.GroupingView or you specify a startGroup-template as config-option "startGroup" to the Ext.grid.GroupingView. Look at the source for more information.

Lukman
16 Jul 2009, 11:30 PM
Here is your plugin. Plug it into the GridPanel that uses that GroupingView:

{
init: function(grid) {
var gview = grid.getView();
gview.startGroup = new Ext.XTemplate(
'<div id="{groupId}" class="x-grid-group {cls}">',
'<div id="{groupId}-hd" class="x-grid-group-hd" style="{[values.rs.length > 1 ? "" : "display:none;"]}"><div class="x-grid-group-title">', gview.groupTextTpl, '</div></div>',
'<div id="{groupId}-bd" class="x-grid-group-body">'
)
}
}

ninoguba
17 Jul 2009, 12:15 AM
Thanks to you both for your suggestions. I have already placed this code to my very first plugin - GroupHeaderVisibility. :D

Lukman
17 Jul 2009, 12:25 AM
I demand some credit! ;) Just kidding :-P

I dug through the source file to get the 'startGroup' part since it is undocumented.