Hi ,
I posted a similar Question on a different form and was pointed to a updated drag and drop heading source.
This seems to solve my problems..
Â
Â
Thanks for the help.
Ryan
Hi Tony,
Thanks for the response.
I was hoping someone else had this problem before and it had been solved already.
here is my JS function to setup drag and drop headings.
It works very well except for my heading name problem.Â
Please see the comments in the code for the problem I am facing.
Thanks again for the help.
Ryan
Â
function SetupDragAndDropHeader() {
$(‘tr.ui-jqgrid-labels th div’).draggable({
appendTo: ‘body’,
helper: ‘clone’
});
$(‘#groups ol’).droppable({
activeClass: ‘ui-state-default’,
hoverClass: ‘ui-state-hover’,
accept: ‘:not(.ui-sortable-helper)’,
drop: function (event, ui) {
var $this = $(this);
$this.find(‘.placeholder’).remove();
var groupingColumn = $(‘
‘).attr(‘data-column’, ui.draggable.attr(‘id’).replace(‘jqgh_’ + gridId + ‘_’, ”));
$(‘‘).click(function () {
$(this).parent().remove();
$(‘#’ + gridId).jqGrid(‘groupingRemove’);
$(‘#’ + gridId).jqGrid(‘groupingGroupBy’, getheader());
// !!!!!!!!!!!!!!!! tried adding here
// setGroupHeaderText();
if ($(‘#groups ol li:not(.placeholder)’).length === 0) {
$(‘
‘).appendTo($this);
}
}).appendTo(groupingColumn);
Â
groupingColumn.append(ui.draggable.text());
groupingColumn.appendTo($this);
$(‘#’ + gridId).jqGrid(‘groupingRemove’);
$(‘#’ + gridId).jqGrid(‘groupingGroupBy’, getheader());
// !!!!!!!!!!!!!!!! Â tried adding here
//This almost works but it sets the first group Name only when you drag and drop a second group.
// the second group then has no group heading name but data as the group name group ie {0}
// adding a third group adds names for the first and second group but the third group has data
//as the group name group ie {0}
setGroupHeaderText();
}
}).sortable({
items: ‘li:not(.placeholder)’,
sort: function () {
$(this).removeClass(‘ui-state-default’);
},
stop: function () {
$(‘#’ + gridId).jqGrid(‘groupingRemove’);
$(‘#’ + gridId).jqGrid(‘groupingGroupBy’, getheader());
// !!!!!!!!!!!!!!!! tried adding here
// setGroupHeaderText();
}
});
}
function getheader()
{
var header = $(‘#groups ol li:not(.placeholder)’).map(function () { return $(this).attr(‘data-column’); }).get();
return header;
}
function setGroupHeaderText()
{
$(‘#’ + gridId).jqGrid(‘setGridParam’,
{
groupingView:
{
groupText: getheader(),
// Future Problem
// groupText: [getheader() + ‘ : {0} ‘],
// on second column drag/drop it adds add heading to first group but it puts the names as
//” Name,Price : John”
// adding a third group changes the first heading to Name,Price,Location : John. The Second and third //group only has data as the group name i.e {0}
groupSummaryPos: ,
groupCollapse: true,
ShowGroupColumn: true
}
});
}
You are a life saver … this was driving me insane.
Works perfectly.
Â
Thanks again.
Ryan
@Rekha said:
Hi,This is regarding Jqgrid Group Header Text displaying Sum in the group Text.
I want the sum of a particular group displayed in the group header. I found this approach on the http://trirand.com/blog/jqgrid/jqgrid.html  demo site and it works. This issue is that, when I am trying to sum a currency, the group text  displays “3117.1499999999996† The extra trailing decimals show up. But when I display on the group Summary, it displays fine as “3117.15â€.
colModel: [ ……….
{ name: ‘Amount’, sortable: true, formatter: ‘currency’, align: “right”, sorttype: ‘currency’, decimalPlaces: ‘2’, summaryType: ‘sum’, defaultValue: ‘0.00’ }]
groupingView: {
                   groupField: ,
                   groupDataSorted: true,
                   groupText: ,
                   groupColumnShow: [true],
                   groupSummary: [true],
                   groupCollapse: true,
                   groupOrder: ,
                   showSummaryOnHide: false,
               },
Please help.
Thank s & Regards
Rekha
Â
Hi,
IÂ also have this exact problem , it does the same with number formatting as well not just currency.Â
I have tried using a function to return the trimmed value but IÂ don’t know how to pass the value {0} or {Amount} Â into the function.
“ groupText: , ”  just passes  in the string
Does anyone know the fix or work around.
I am desperate.
Â
Thanks
Ryan
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top