0

对不起,但我不明白我做错了什么。我从服务器获取 json 并希望对列应用排序。渲染网格后,我可以看到标题中的列看起来像排序但数据仍然未排序

在此处输入图像描述

我用于创建网格的 javascript 是:

var gridDefinition = window['personalExpensesGridModel'];

gridDefinition.sortname = 'Type';
gridDefinition.sortorder = 'desc';
grid.jqGrid(gridDefinition);

为每一列定义了排序类型。在这里您可以看到配置对象:

在此处输入图像描述

更新1

{
    "autowidth": true,
    "gridid": "RegExpGeneral",
    "url": null,
    "datatype": "jsonstring",
    "colModel": [
        {
            "key": false,
            "name": "Status",
            "label": " ",
            "settingsCaption": "Status",
            "resizable": false,
            "fixed": true,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 25,
            "hidden": false,
            "columnSettingsType": "alwaysvisible"
        },
        {
            "key": false,
            "name": "Type",
            "label": "<span title='???'>Type</span>",
            "settingsCaption": "Type",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 194,
            "hidden": false,
            "columnSettingsType": "alwaysvisible"
        },
        {
            "key": false,
            "name": "ExpenseCategory",
            "label": "&nbsp;",
            "settingsCaption": "ExpenseCategory",
            "resizable": false,
            "fixed": true,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 25,
            "hidden": false,
            "columnSettingsType": "alwaysvisible"
        },
        {
            "key": false,
            "name": "Description",
            "label": "<span title='???'>Description</span>",
            "settingsCaption": "Description",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 91,
            "hidden": false,
            "columnSettingsType": "alwaysvisible"
        },
        {
            "key": false,
            "name": "Customer",
            "label": "<span title='???'>Customer</span>",
            "settingsCaption": "Customer",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 157,
            "hidden": false,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "Project",
            "label": "<span title='???'>Project</span>",
            "settingsCaption": "Project",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 250,
            "hidden": false,
            "columnSettingsType": "alwaysvisible"
        },
        {
            "key": false,
            "name": "Activity",
            "label": "<span title='???'>Activity</span>",
            "settingsCaption": "Activity",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 197,
            "hidden": false,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "NotesOrAttendees",
            "label": "&nbsp;",
            "settingsCaption": "NotesOrAttendees",
            "resizable": false,
            "fixed": true,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 25,
            "hidden": false,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "Number",
            "label": "<span title='???'>Kms</span>",
            "settingsCaption": "Kms",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "Global.Grid.SortNumbers",
            "frozen": false,
            "width": 103,
            "hidden": false,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "IntendDate",
            "label": "<span title='???'>Date</span>",
            "settingsCaption": "Date",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 50,
            "hidden": true,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "CostInCurrency",
            "label": "<span title='???'>Original Amount</span>",
            "settingsCaption": "Original Amount",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "Global.Grid.SortNumbers",
            "frozen": false,
            "width": 80,
            "hidden": true,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "Vat",
            "label": "<span title='???'>Vat</span>",
            "settingsCaption": "Vat",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "Global.Grid.SortNumbers",
            "frozen": false,
            "width": 80,
            "hidden": true,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "CostExchangeRate",
            "label": "<span title='???'>Exchange Rate</span>",
            "settingsCaption": "Exchange Rate",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "Global.Grid.SortNumbers",
            "frozen": false,
            "width": 40,
            "hidden": true,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "Compensation",
            "label": "<span title='???'>Compensation</span>",
            "settingsCaption": "Compensation",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "Global.Grid.SortNumbers",
            "frozen": false,
            "width": 65,
            "hidden": false,
            "columnSettingsType": "alwaysvisible"
        },
        {
            "key": false,
            "name": "CustomerPrice",
            "label": "<span title='???'>Customer price</span>",
            "settingsCaption": "Customer price",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "Global.Grid.SortNumbers",
            "frozen": false,
            "width": 80,
            "hidden": true,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "Chargeability",
            "label": "<span title='???'>Not chargeable</span>",
            "settingsCaption": "Not chargeable",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 20,
            "hidden": true,
            "columnSettingsType": "regular"
        },
        {
            "key": false,
            "name": "Actions",
            "label": "&nbsp;",
            "settingsCaption": "Actions",
            "resizable": false,
            "fixed": true,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": 25,
            "hidden": false,
            "columnSettingsType": "noconfig"
        },
        {
            "key": true,
            "name": "TransId",
            "label": "&nbsp;",
            "settingsCaption": "TransId",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": null,
            "hidden": true,
            "columnSettingsType": "noconfig"
        },
        {
            "key": false,
            "name": "IsValid",
            "label": "&nbsp;",
            "settingsCaption": "IsValid",
            "resizable": true,
            "fixed": false,
            "sortable": true,
            "sorttype": "text",
            "frozen": false,
            "width": null,
            "hidden": true,
            "columnSettingsType": "noconfig"
        }
    ],
    "altRows": true,
    "width": null,
    "height": 415,
    "shrinkToFit": true,
    "jsonReader": {
        "repeatitems": false
    },
    "datastr": {
        "userdata": null,
        "total": 1,
        "page": 1,
        "records": 78,
        "rows": [
            {
                "Status": "<img src='/PXControl/Content/images/expenses/grid/pe_status_saved.png' alt='SA' title='Saved' />",
                "Type": "Travelcompclass U1 (TEST) (U1)",
                "ExpenseCategory": "<img src='/PXControl/Content/images/expenses/grid/expenses.png' alt='E' title='General' />",
                "Description": "",
                "Customer": "Construction Enterprice",
                "Project": "301952 - Syncron International AB, löpande konsultation PX Control.",
                "Activity": "10 - Ej debiterbar tid hos kund",
                "NotesOrAttendees": "",
                "Number": "",
                "IntendDate": "",
                "CostInCurrency": "",
                "Vat": "0,00",
                "CostExchangeRate": "",
                "Compensation": "3,00",
                "CustomerPrice": "0,00",
                "Chargeability": "No",
                "Actions": "<a class=\"edit-link\" data-ajax=\"true\" data-ajax-method=\"POST\" data-ajax-mode=\"replace\" data-ajax-success=\"Global.PersonalExpenses.afterAjax()\" data-ajax-update=\"#px-expenses-page-container\" href=\"/PXControl/Reg/TimeExpenses/GeneralExpense?period=201152%20%20&amp;versionCode=U&amp;transId=33024&amp;statusFilter=All&amp;doSubmit=False\">edit</a><a data-ajax=\"true\" data-ajax-begin=\"Global.PersonalExpenses.saveFormData()\" data-ajax-method=\"POST\" data-ajax-mode=\"replace\" data-ajax-success=\"Global.PersonalExpenses.afterAjax()\" data-ajax-update=\"#px-expenses-page-container\" href=\"/PXControl/Reg/TimeExpenses/Delete?period=201152%20%20&amp;versionCode=U&amp;transId=33024&amp;category=General&amp;page=General\"><img src=\"/PXControl/Content/images/expenses/grid/delete_normal.png\" /></a>",
                "TransId": "33024",
                "IsValid": "1"
            },
            {
                "Status": "<img src='/PXControl/Content/images/expenses/grid/pe_status_saved.png' alt='SA' title='Saved' />",
                "Type": "Travelcompclass U1 (TEST) (U1)",
                "ExpenseCategory": "<img src='/PXControl/Content/images/expenses/grid/expenses.png' alt='E' title='General' />",
                "Description": "",
                "Customer": "Search Engine Marketing Company",
                "Project": "301395 - Utbildning Visma Business",
                "Activity": "ANV - .",
                "NotesOrAttendees": "",
                "Number": "",
                "IntendDate": "",
                "CostInCurrency": "",
                "Vat": "0,00",
                "CostExchangeRate": "",
                "Compensation": "1 000,00",
                "CustomerPrice": "1000,00",
                "Chargeability": "Yes",
                "Actions": "<a class=\"edit-link\" data-ajax=\"true\" data-ajax-method=\"POST\" data-ajax-mode=\"replace\" data-ajax-success=\"Global.PersonalExpenses.afterAjax()\" data-ajax-update=\"#px-expenses-page-container\" href=\"/PXControl/Reg/TimeExpenses/GeneralExpense?period=201152%20%20&amp;versionCode=U&amp;transId=32735&amp;statusFilter=All&amp;doSubmit=False\">edit</a><a data-ajax=\"true\" data-ajax-begin=\"Global.PersonalExpenses.saveFormData()\" data-ajax-method=\"POST\" data-ajax-mode=\"replace\" data-ajax-success=\"Global.PersonalExpenses.afterAjax()\" data-ajax-update=\"#px-expenses-page-container\" href=\"/PXControl/Reg/TimeExpenses/Delete?period=201152%20%20&amp;versionCode=U&amp;transId=32735&amp;category=General&amp;page=General\"><img src=\"/PXControl/Content/images/expenses/grid/delete_normal.png\" /></a>",
                "TransId": "32735",
                "IsValid": "1"
            },
            {
                "Status": "<img src='/PXControl/Content/images/expenses/grid/pe_status_saved.png' alt='SA' title='Saved' />",
                "Type": "Travelcompclass F1 (F1)",
                "ExpenseCategory": "<img src='/PXControl/Content/images/expenses/grid/mileage.png' alt='M' title='TaxMileage' />",
                "Description": "$$changed price",
                "Customer": "Construction Enterprice",
                "Project": "301952 - Syncron International AB, löpande konsultation PX Control.",
                "Activity": "10 - Ej debiterbar tid hos kund",
                "NotesOrAttendees": "",
                "Number": "100",
                "IntendDate": "2011-12-27",
                "CostInCurrency": "",
                "Vat": "0,00",
                "CostExchangeRate": "",
                "Compensation": "340,00",
                "CustomerPrice": "5000,00",
                "Chargeability": "Yes",
                "Actions": "<a class=\"edit-link\" data-ajax=\"true\" data-ajax-method=\"POST\" data-ajax-mode=\"replace\" data-ajax-success=\"Global.PersonalExpenses.afterAjax()\" data-ajax-update=\"#px-expenses-page-container\" href=\"/PXControl/Reg/TimeExpenses/Mileage?period=201152%20%20&amp;versionCode=U&amp;transId=32731&amp;statusFilter=All\">edit</a><a data-ajax=\"true\" data-ajax-begin=\"Global.PersonalExpenses.saveFormData()\" data-ajax-method=\"POST\" data-ajax-mode=\"replace\" data-ajax-success=\"Global.PersonalExpenses.afterAjax()\" data-ajax-update=\"#px-expenses-page-container\" href=\"/PXControl/Reg/TimeExpenses/Delete?period=201152%20%20&amp;versionCode=U&amp;transId=32731&amp;category=Mileage&amp;page=General\"><img src=\"/PXControl/Content/images/expenses/grid/delete_normal.png\" /></a>",
                "TransId": "32731",
                "IsValid": "1"
            }
        ]
    },
    "scroll": 1,
    "sortable": true,
    "loadonce": true,
    "viewrecords": true,
    "userDataOnFooter": false,
    "sortname": "TransId",
    "sortorder": "desc",
    "savesettingsurl": "/PXControl/Reg/TimeExpenses/SaveGridSettings",
    "loadsettingsurl": "/PXControl/Reg/TimeExpenses/RevertGridSettings",
    "grouping": false,
    "groupingView": null,
    "rowNum": 2147483647
}
4

1 回答 1

0

您如何在演示中看到您发布的代码对排序没有问题:

在此处输入图像描述

于 2012-11-22T14:04:47.170 回答