Author Topic: Sort issue with Grid  (Read 359 times)

pranit@srcomsec

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 99
    • View Profile
Sort issue with Grid
« on: February 02, 2023, 12:40:53 pm »
As per the screenshot attached, I am trying to sort column "B.Qty" but it is not working. Looks like sort as string in place of number.

Please review the grid properies below and advise.

Code: [Select]
$(function ()
{
var pqVS = {
rpp: 3000, //records per page.
init: function () {
this.totalRecords = 0;
this.requestPage = 1; //begins from 1.
this.data = [];
}
};
pqVS.init();

var obj =
{
width: "auto",
numberCell: { width: 30, show: false },
//title: "Virtual Scrolling",
resizable: true,
filterModel: { on: true, header: false, type: 'local', menuIcon: true, hideRows: false },
menuIcon: true,
sortModel: { type: 'local' },
pageModel: { rPP: 3000 },
selectionModel: { type: 'row', mode: 'block', column: false, row: true },
blur: function (evt, ui)
{
mGridUIFocus = ui; //global var
},
editable: false,
stripeRows: false,      //Remove alternate row color
strNoRows: 'No Scripts found.',
dragModel: {
on: true,
diDrag: "stExchange",
},
dropModel: {
on: true,
isDroppable: function (evt, ui) {
var lochkPauseID = this.element[0].id.replace("gridfilter", "chkPausetbl");
$("#" + lochkPauseID).prop("checked", true);
},
},
colModel: fsTableHeaders,
rowInit: function (ui)
{
if ($("#hfWorkSpaceBox" + fiTableIndex + "SMParameter").val() != "") {
var loStrategyMasterJS = $.parseJSON($("#hfWorkSpaceBox" + fiTableIndex + "SMParameter").val());
//console.log(loStrategyMasterJS);

if (loStrategyMasterJS.stTableBGColor != "" && loStrategyMasterJS.stTableBGColor != "null") {
return {
style: { "background": loStrategyMasterJS.stTableBGColor } //can also return attr (for attributes) and cls (for css classes) properties.
};
}
}
},
cellSave: function (evt, ui) {
this.refreshRow({ rowIndx: ui.rowIndx });
},

create: function () {
var lsParamQueryGridState = $("#hfParamQueryGridState" + fiTableIndex).val();
if (lsParamQueryGridState != "null" && lsParamQueryGridState != "" && $("#gridfilter" + fiTableIndex).hasClass('pq-grid'))
$("#gridfilter" + fiTableIndex).pqGrid("loadState", { state: lsParamQueryGridState, refresh: false });
},
change: function () {
this.filter();
},

beforeCellClick: function(evt, ui){
if( !evt.ctrlKey && this.SelectRow().isSelected(ui)){
   return false;
}
},
moveNode: function () {
var lochkPauseID = this.element[0].id.replace("gridfilter", "chkPausetbl");
saveMarketWatchScriptRowIndex(fiTableIndex);
},
};

var fiType = parseInt($('#ddltbl' + fiTableIndex + 'Exchange').val());
var liGroupID = parseInt($('#ddltbl' + fiTableIndex + 'Group').val());
var lsStrategyUID = $('#ddlStrategyMastertbl' + fiTableIndex).val();
if (lsStrategyUID == "0" || lsStrategyUID == undefined || lsStrategyUID == null)
lsStrategyUID = "";
var fsColumnList = "";
$.each(fsTableHeaders, function (i, item) {
fsColumnList += fsTableHeaders[i].dataIndx + ",";
});

obj.dataModel =
{
method: "GET",
dataType: "JSON",
/*location: "remote",*/
location: "lazy",
url: "WEB API URL",
data: [],

postData: function () {

return {
pq_curpage: pqVS.requestPage,
pq_rpp: pqVS.rpp,
pq_type: fiType,
pq_group_id: liGroupID,
pq_strategy_uid: lsStrategyUID,
pq_column_list: fsColumnList,
};
},

error: function (jqXHR, textStatus, errorThrown) {
//alert(errorThrown);
}
};

var grid = $("#gridfilter" + fiTableIndex).pqGrid(obj,
{
scroll: function () {
mGridUIScrollX = this.scrollX();
mGridUIScrollY = this.scrollY();
},

rowClick: function (event, ui) {
//console.log(ui);
$("#hfSelectedRowIndex" + fiTableIndex).val(ui.rowIndx);
$("#hfLastTableIndexClicked").val(fiTableIndex);
},
});
}

« Last Edit: February 02, 2023, 12:46:11 pm by pranit@srcomsec »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Sort issue with Grid
« Reply #1 on: February 02, 2023, 06:52:19 pm »
The values in the column received from your remote script should be numbers rather than strings e.g. 9046 instead of "9046"

pranit@srcomsec

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 99
    • View Profile
Re: Sort issue with Grid
« Reply #2 on: February 02, 2023, 06:59:05 pm »
Thank you for your quick response.

I have added "dataType" with colModel to each column to fix this issue.