1
Help for ParamQuery Pro / Unable to get event used for sorting
« on: December 06, 2016, 02:37:45 pm »
I am not able to get the datatype of the column,by which sorting is not happening correctly
Please find the code below
Please let me know how to capture sorting event in param query grid while initializing.
Please find the code below
Code: [Select]
var records=[];
records = JSON.parse($('#hiddenresults').val());
$.each(records, function (i, data)
{
if (data.Name == "Main")
mainData = data;
});
var columnModel = [
{
title: "Name", dataIndx: "Name", width: 150, align: "left",
dataType: function (val1, val2) {
return stringSort(val1, val2);
}
},
{
title: "Interval", dataIndx: "Interval", width: 155, align: "left",
//dataType:"integer",
render: function (ui) {
var rowData = ui.rowData;
var isMain =rowData.UseMain;
var dataIndx = ui.dataIndx;
var cellData = rowData[dataIndx];
if (isMain == true)
cellData = mainData.Interval;
return "<span >" + cellData + "</span>";
},
dataType: function (val1, val2) {
return stringSort(val1, val2);
}
},
{
title: "Exists", dataIndx: "HasValue", width: 100, align: "left",
render: function (ui) {
var rowData = ui.rowData;
var dataIndx = ui.dataIndx;
var cellData = rowData[dataIndx];
var isMain =rowData.HasValue;
var hasVal = "No";
if (isMain == true) {
if (mainData.HasValue)
hasVal = "Yes";
}
else {
if (cellData != undefined && cellData != null && cellData == true)
hasVal = "Yes";
}
return "<span >" + hasVal + "</span>";
},
dataType: function (val1, val2) {
return stringSort(val1, val2);
}
}
];
resultsGrid.pqGrid({
width: 1000,
height: 160,
editable: false,
showTop: false,
showBottom: false,
numberCell: false,
roundCorners: false,
wrap: false,
colModel: columnModel,
dataModel: { data: records },
hoverMode: 'row',
selectionModel: { type: 'row', mode: 'single' },
virtualY: true,
virtualX: true,
rowSelect: function (event, ui) {
selectedRecord = ui.rowData;
},
refresh: function (evt, ui) {
var $grid = $(this),
virtualY = $grid.pqGrid('option', 'virtualY'),
length = $grid.pqGrid('pageData').length,
val = (length > 50) || (length == 0);//any cutoff number in place of 20
if (val !== virtualY) {
$grid.find(".pq-sb-vert").pqScrollBar("option", "steps", val);
$grid.pqGrid('option', 'virtualY', val).pqGrid('refresh');
}
}
});
function stringSort = function (val1, val2) {
var c1 = $.trim(val1).toLowerCase();
var c2 = $.trim(val2).toLowerCase();
if (c1 > c2) {
return 1;
}
else if (c1 < c2) {
return -1;
}
else {
return 0;
}
}
Please let me know how to capture sorting event in param query grid while initializing.