I have a column "Amount" on the jqGrid. When I click on top of "Amount" column, the grid needs to be sorted by another column called "Amount Payable".
How can I achieve this.
Thanks, Sam
I have a column "Amount" on the jqGrid. When I click on top of "Amount" column, the grid needs to be sorted by another column called "Amount Payable".
How can I achieve this.
Thanks, Sam
You don't posted the code of jqGrid which you use. What you should try to do as the first is the set index
property for Amount
column in the value of name of column which you called as "Amount Payable"`.
Another way would be to use sorttype
property for Amount
column defined as function. The way works in case of usage datatype: "local"
or in case of usage loadonce: true
option with remote datatype
("json", "jsonp" or "xml"). What you need to do is just add sorttype
property for Amount
column defined about as following:
{
name: "Amount",
sorttype: function (cellValue, rowData) {
return rowData.AmountPayable; // use the value from another column for
// defining of the position of sorted rows
}}
See the answer or this one for another code examples.
If you define the onSortCol
function you could test for the column being sorted and then change the value.
Ex.
onSortCol: function (index, iCol, sortorder) {
if(index === "Amount"){
index = "AmountPayable";
}
},