Is it possible to display row group summary text with group Value..
As shown in above, I want to set text "total" As "Gwadar-Total" and so on.
How can I achieve this at run time, which get Text from row group and display with summary Text?
I am using "summaryTpl" in cell modal.
from http://www.trirand.com/jqgridwiki/doku.php?id=wiki:grouping
you can use custom summaryType
function mysum(val, name, record)
{
return parseFloat(val||0) + parseFloat((record[name]||0));
}
jQuery("#grid").jqGrid({
...
colModel : [
{..},
{name:'amount',index:'amount', width:80, align:"right", sorttype:'number',formatter:'number',summaryType:mysum},
...
],
...
});
regards,
aramadhani
Try this
$('#gridName tr[jqfootlevel="0"] td').each(function () {
$(this).html($(this).html().replace('Total','Main Group Level Total'));
});
Related
I would like to be able to programmatically select something from a dropdown, as in http://select2.github.io/select2/#programmatic. But the dropdown also seems to be generated (I didn't include it anywhere in the HTML) by the filterformatter widget, which I initialized with:
$('#client_table').tablesorter({
theme: "blue",
headers: {1: {sorter: 'types'}},
widgets: ["filter", "zebra"],
widgetOptions : {
filter_formatter: {
1 : function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
closeOnSelect: false,
placeholder: "Select events",
allowClear: true,
match: false, // exact match only
});
},
What element do I call select2 on in this case? What are the values/data that I should be using (the thing I would like to select, for example, is the string APP_STATE).
When select2 is applied to the table, the table cell gets a class name of select2col0 where (0 is the column zero-based index).
If you open this demo and enter the following code in the console, it'll programmically set the value:
$('.select2col0').find('input').select2('val', ['abc']);
I am trying to make a grid groupable on columns field but the columns are object.
{
Gestionnaire :
{ id: 4, nom:'nomgestionnaire'},
{..},
..
}
I have success for sortable:
columns: [
field: "Gestionnaire"
title: "Gestionnaire"
sortable:
compare: (a,b) =>
#compareColumnFields(a.Gestionnaire.Nom, b.Gestionnaire.Nom)
]
with #compareColumnFields function is :
if a is b
return 0
else if a > b
return 1
else
return -1
and for groupable?
groupable : ...
I think you're wanting to allow the user to actively group columns.
In that case, all you need is:
groupable: true
in the main structure of the grid.
For example:
$('#grid').kendoGrid({
columns: [
{
fields: "Guestionaire",
title: "Guestionaire",
sortable:
compare: (a,b) =>
#compareColumnFields(a.Guestionaire.Nom, b.Guestionaire.Nom)
},
{...placeholder for other columns...}
],
groupable: true
});
Kendo has a sample of this at http://dojo.telerik.com/ejehe
Ignore the SelectRow and Expand/Collapse stuff and that ought to be the same as what you're trying to accomplish.
For those in the same situation as me , I completely change solution. Instead of making me a function that returns true and false , it giving it the object in full, I just give the string .
For my example I give directly a.Gestionnaire.Nom and b.Gestionnaire.Nom, and THEN you can call :
groupable: true
In fact it was obvious.
Here is the Example created - Pivot Table JSFiddle example: here
groupingView: {
groupField: ['ComponentType'],
groupColumnShow: [false],
groupDataSorted: true,
groupOrder: "desc"
}, /*Is not working properly, when i click sort on ComponentType, group headers are not sorting*/
Need help to display ComponentType(group header) in desc order.
Thanks
First of all you have to fix the grouping options options which you use. You have to use
groupOrder: ["desc"]
instead of
groupOrder: "desc"
The main problem with ignoring of "desc" grouping order exist already in old version of jqGrid (see the line of jqGrid 4.6 and the line of jqGrid 4.7).
I fixed the code in free jqGrid. The demo which uses the latest version of free jqGrid from GitHub don't have more the described problem: https://jsfiddle.net/OlegKi/bkqce0s0/11/
If you have to use old version of free jqGrid of jqGrid then you can solve the problem by changing datatype from "jsonstring" to "local":
onInitGrid: function () {
var p = $(this).jqGrid("getGridParam"),
userdata = p.datastr.userdata;
// filter the data and remove some items
p.data = $.grep(p.datastr, function (item) {
return item.ComponentType !== "";
});
p.userData = userdata;
p.datatype = "local";
}
The demo http://jsfiddle.net/OlegKi/bkqce0s0/12/
I have a jqGrid that I set up like this
gridAltMpn.jqGrid({
autowidth: true,
shrinkToFit: true,
datatype : 'local',
data : input,
height : '100',
scrollrows: true,
scrollOffset : '0',
hidegrid : false,
colNames : [ 'P', 'MPN' ],
colModel : [
{ name : 'Col1', width : 30, align:'center' },
{ name : 'Col2', width : 250, sorttype: 'integer'}
],
pager : '#altmpn_pager',
pagerpos : 'left',
scroll: 50,
gridview : true,
caption : 'A useful table title',
emptyRecordText : '<div id="no_data_msg" style="text-align:center"> No Results Found</div>',
hoverrows : true,
onSelectRow: function(id) {
var gsr = gridAltMpn.jqGrid('getGridParam', 'selrow');
if (gsr) {
var rowData = gridAltMpn.jqGrid('getRowData', gsr);
if ($("input[name='optInvInqType']:checked").val() == 'MPN') {
getInvInq("MPN", rowData.MPN);
}
}
},
loadComplete: function() {
gridAltMpn.setSelection(gridAltMpn.getDataIDs()[0], true);
}
});
The data in this grid looks like this
XX 774860A6
774860A8
774860A4
774860A3
774860A10
STARTER, PNEUM,PW4000
When the grid is first loaded that it fine but if the user wants to sort by the second column it ends up like this
774860A10
774860A3
774860A4
XX 774860A6
774860A8
STARTER, PNEUM,PW4000
The 774860A10 should go after the 774860A8 just like in an integer sort. I cannot use an integer sort because these are not integers as there is some alpha characters in there. In other words I want a text entry to sort like an integer. Do I need to use a custom sort routine and then have my Javascript to do a integer like sort? I also don't need this sorted on the first time because my server sorts it by the first column. The user might want it sorted by the second column
You should use a custom function for this type of sorting.
For this, set sort type property of jqgrid as your custom function. As stated in this link, sort type can have the following values.
sorttype:
int/integer - for sorting integer
float/number/currency - for sorting decimal numbers
date - for sorting date
text - for text sorting
function - defines a custom function for sorting. To this function we pass the value to be sorted and it should return a value too.
And the custom function can be something like this: (From this link found in the answer by Oleg for this question.)
colModel: [
{name:'Posn', index:'Posn', width:100, sorttype:
function(cell)
{
//Here you have to apply your own logic
if (cell=='GK') return '0';//returns the sort order
if (cell=='DEF') return '1';
if (cell=='MID') return '2';
if (cell=='STR') return '3';
}
},
By the way, you can set the sortname property of jqgrid to set a column for initial loadtime sorting.
I have a JQGrid that groups together certain rows. I use group to define what rows should grouped together, so for example, if there are three 2s, it groups all 2s together. However it's possible there could be only one 2, in which case I wouldn't want it grouped, i.e. having the row under a group.
My question is, is it possible to have the grouping only be applied to certain rows and leave others alone?
Below is what I currently have:
colNames:['group', 'Description', 'File Sent to Customer', 'Date/Time', 'ATS', '# of Bib Records', '# of Items', 'Customer DB', 'Customer ID'],
colModel:[
{name:'group', index:'group'},
{name:'description', index:'description'},
{name:'fileSent', index:'fileSent', width:150},
{name:'date', index:'date', width:160},
{name:'ats', index:'ats', width:100},
{name:'bibRecords', index:'bibRecords', width:100},
{name:'items', index:'items', width:100},
{name:'customerDB', index:'customerDB', width:240},
{name:'customerID', index:'customerID', width:150}
],
grouping:true,
groupingView : {
groupField : ['group'],
groupColumnShow : [false],
groupText : [''],
groupCollapse : true,
groupOrder: ['desc']
},
I find your question interesting. So I wrote the solution which shows instead of the standard grouping (see the starting demo)
the following:
The corresponding code is not so complex:
loadComplete: function () {
var i, groups = $(this).jqGrid("getGridParam", "groupingView").groups,
l = groups.length,
idSelectorPrefix = "#" + this.id + "ghead_0_";
for (i = 0; i < l; i++) {
if (groups[i].cnt === 1) {
// hide the grouping row
$(idSelectorPrefix + i).hide();
}
}
}
It uses one level grouping, but it can be changed in the same way to the multilevel grouping.
One warning about the resulting grid: you should be careful with sorting of the grid. The problem is that jqGrid sort the rows inside of the group only. So the above rows with hidden grouping headers seems be out of sorting process.