简体   繁体   中英

sorting dates in jqgrid

The date column is not being sorted properly on client, see my code, last column is the date one and the date comes in dd-MMM-YYYY format - eg 13-Jul-2020

Anything off here?

 $('#myGrid').jqGrid({
        datatype: 'local',
        url: pathvar
        jsonReader: common.jqgrid.jsonReader(),
        mtype: 'POST',
        colNames: [
            'Quote Id', 'Client', 'Title', 'Assignee', 'Due Date'],

        colModel: [
            {
                name: 'QuoteId',
                index: 'QuoteId',
                width: 10,
                sortable: false,
                search: false                    
            },
            {
                name: 'ClientCode',
                index: 'ClientCode',
                width: 10,
                sortable: false,
                search: false,
                formatter: WebView.followups.onClientLinkFormatter
            },
            {
                name: 'Title',
                index: 'Title',
                width: 30,
                sortable: false,
                search: false,
                hidden: true
            },
            {
                name: 'AssignedUser',
                index: 'AssignedUser',
                width: 20,
                sortable: false,
                search: true
            },
            {
                name: 'DueDate',
                index: 'DueDate',
                width: 15,
                sortable: true,
                search: false,
                sorttype: 'date',
                srcformat: 'DD-MMM-YYYY',                   
                formatoptions: { newformat: 'DD-MMM-YYYY' }
            }

        ],

        scroll: false,
        hidegrid: false,
        height: 400,
        width: 1000,
        rowNum: 1000,
        altRows: true,
        loadonce: true,
        sortable: true,
        altclass: 'gridAltRowClass',
        loadComplete: function (data) {},
        gridComplete: function () {

 var rows = $("#quoteFollowupsGrid").getDataIDs();
                for (var i = 0; i < rows.length; i++) {
                    var duedate = $("#quoteFollowupsGrid").getCell(rows[i], "DueDate");

                    const today = moment();
                    var rowDueDate = moment(duedate, 'DD-MMM-YYYY'); // new Date(duedate + "00:00:00");

                    if (rowDueDate == today)
                        $("#quoteFollowupsGrid").jqGrid('setRowData', rows[i], false, { background: '#c6e3c4' });
                    else if (rowDueDate < today)
                        $("#quoteFollowupsGrid").jqGrid('setRowData', rows[i], false, { background: '#ffc4d2' });
                }

        }

    });

In Guriddo jqGrid JS this is a bug. If you use this version, please write a email to the support to receive the fixed version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM