Forum
17:33
24/03/2014
When I use grouping and the groupSummaryPos is specified as “header”, the summary total ends up in the wrong column.
(function() {
$(document).ready(function() {
var txHistoryLineItems = [];
var txHistoryLineItems1 = {
id: 1,
col1: 'Jake',
col2: 'Smith',
col3: 44,
col4: 113,
col5: 'Some Description'
};
var txHistoryLineItems2 = {
id: 1,
col1: 'Joan',
col2: 'Thomas',
col3: 44,
col4: 113,
col5: 'Another Description'
};
txHistoryLineItems.push(txHistoryLineItems1);
txHistoryLineItems.push(txHistoryLineItems2);
var $historyGrid = $("#historyGrid");
$historyGrid.jqGrid({
// Allow columns to be dragged
sortable: true,
data: txHistoryLineItems,
datatype: 'local',
colNames: ["ID", "Column 1", "Column 2", "Column 3", "Column 4", "Column 5"
],
colModel: [
{name: "id", index: "id", hidden: true, frozen: true},
{name: "col1", index: "col1"},
{name: "col2", index: "col2", sortable: false},
{name: "col3", index: "col3", draggable: false},
// Add a summary type property for grouping total
{name: "col4", index: "col4", resizable: false, summaryType:'sum', align: "right", formatter: "currency", formatoptions: {decimalPlaces: 2, prefix: '$'}},
{name: "col5", index: "col5"}
],
// footerrow: true,
// userDataOnFooter: true,
// Enable grouping
grouping: true,
groupingView : {
useColSpanStyle: true,
// Whether to show the grouping column
groupColumnShow : [false],
// Formatting for the group header {0} is the value, {1} is the count
groupText : ['<b>{0} ({1})</b>'],
groupCollapse : true,
// Whether to show the group summary
groupSummary : [true],
// Put summary total at header or footer area -- putting on header causes a problem.
groupSummaryPos: ['header'],
// Allow summary total row to show on a grouping collapse.
showSummaryOnHide: true
},
// Add header titles to the column headers
headertitles: true,
// Allow multiple columns to be sorted by the user.
multiSort: true,
rowNum: 500,
height: 375,
width: 500,
shrinkToFit: false
});
$("#chngroup").change(function(){
var vl = $(this).val();
if(vl) {
if(vl == "clear") {
$historyGrid.jqGrid('groupingRemove',true);
} else {
$historyGrid.jqGrid('groupingGroupBy',vl);
}
}
});
});
}());
12:20
Moderators
30/10/2007
Hello,
It all depend how is defined your content - i.e the value of vl in change event.
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
14:35
24/03/2014
tony said:
Hello,
It all depend how is defined your content - i.e the value of vl in change event.
Regards
In the example above if I set the vl value to group by col4, the grouping total is listed in the col5 header. This example works correctly if I set the groupSummaryPos value to "footer" instead of "header".
07:24
Moderators
30/10/2007
Hello,
I see the id column is set to frozen. Do you call somewhere in your script the frozen column.
Please in the future give us the whole test case. This way you will get help.
Without a test case I can not help.
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
14:45
24/03/2014
tony said:
Hello,
I see the id column is set to frozen. Do you call somewhere in your script the frozen column.
Please in the future give us the whole test case. This way you will get help.
Without a test case I can not help.
Regards
Apologies -- I was playing around trying to get around this issue. Here's the full snippet. Note: If I enable the multiselect property, the summary total correctly shows up under column 4 when I perform a grouping. If I disable the multiselect property, the summary total incorrectly shows up under column 5 when I perform the grouping.
(function() {
// Get the JSON data from the server.
$(document).ready(function() {
// We can read in JSON directly into the grid, but this provides us a way to perform
// any transformation before we add the data to the grid?
var txHistoryLineItems = [];
var txHistoryLineItems1 = {
id: 1,
col1: 'Jake',
col2: 'Smith',
col3: 44,
col4: 113,
col5: 'Some Description'
};
var txHistoryLineItems2 = {
id: 2,
col1: 'Joan',
col2: 'Thomas',
col3: 44,
col4: 113,
col5: 'Line1\nLine2\nLine3\Line4'
};
var txHistoryLineItems3 = {
id: 3,
col1: 'John',
col2: 'Mott',
col3: 44,
col4: 113,
col5: 'Another Description'
};
txHistoryLineItems.push(txHistoryLineItems1);
txHistoryLineItems.push(txHistoryLineItems2);
txHistoryLineItems.push(txHistoryLineItems3);
var $historyGrid = $("#historyGrid");
$historyGrid.jqGrid({
// Allow columns to be dragged
sortable: false,
data: txHistoryLineItems,
datatype: 'local',
colNames: ["ID", "Column 1", "Column 2", "Column 3", "Column 4", "Column 5"
],
colModel: [
{name: "id", index: "id", hidden: true, frozen: true},
{name: "col1", index: "col1", frozen: true},
{name: "col2", index: "col2", sortable: false},
{name: "col3", index: "col3", draggable: false},
// Add a summary type property for grouping total
{name: "col4", index: "col4", resizable: false, summaryType:'sum', align: "right", formatter: "currency", formatoptions: {decimalPlaces: 2, prefix: '$'}},
{name: "col5", index: "col5"}
],
grouping: true,
groupingView : {
useColSpanStyle: true,
// Whether to show the grouping column
groupColumnShow : [false],
// Formatting for the group header {0} is the value, {1} is the count
groupText : ['<b>{0} ({1})</b>'],
groupCollapse : true,
// Whether to show the group summary
groupSummary : [true],
// Put summary total at header or footer area -- putting on header causes a problem.
// groupSummaryPos: ['footer'],
groupSummaryPos: ['header'],
// Allow summary total row to show on a grouping collapse.
showSummaryOnHide: true
},
// Add header titles to the column headers
headertitles: true,
// Allow multiple columns to be sorted by the user.
multiSort: true,
// Allow multiple rows to be selected.
// multiselect: true,
rowNum: 500,
height: 375,
width: 500,
shrinkToFit: false
});
$historyGrid.jqGrid('setFrozenColumns');
$("#chngroup").change(function(){
var vl = $(this).val();
if(vl) {
if(vl == "clear") {
$historyGrid.jqGrid('groupingRemove',true);
} else {
$historyGrid.jqGrid('groupingGroupBy',vl);
}
}
});
});
}());
Most Users Ever Online: 715
Currently Online:
28 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66