2013-04-16 19 views
0

我在jqGrid上有一列「Amount」。當我點擊「金額」列的頂部時,網格需要被稱爲「應付金額」的另一列進行排序。jqgrid:如何在不同的列上排序

我該如何做到這一點。

感謝, 山姆

回答

0

如果定義onSortCol功能,您可以測試該列進行排序,然後更改值。

Ex。

onSortCol: function (index, iCol, sortorder) {  
    if(index === "Amount"){ 
     index = "AmountPayable";    
    } 
}, 
1

您沒有發佈您使用的jqGrid的代碼。你應該嘗試做的第一項是屬性設置Amount列的屬性名稱的值,你稱爲「應付金額」。

另一種方法是使用sorttype屬性爲Amount列定義爲函數。該方法適用於使用情況datatype: "local"或使用情況loadonce: true選項與遠程datatype(「json」,「jsonp」或「xml」)。您需要做的僅僅是添加sorttype屬性有關定義如下Amount柱:

{ 
    name: "Amount", 
    sorttype: function (cellValue, rowData) { 
     return rowData.AmountPayable; // use the value from another column for 
             // defining of the position of sorted rows 
    }} 

瞭解其他代碼示例the answerthis one