[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Can't sort by date on jqgrid

Posted on 2011-09-12
1
Medium Priority
?
1,339 Views
Last Modified: 2013-11-19
Hi,

I'm very new to jquery and need some urgent help.  I have a jqgrid which is returning data, however, it needs to be sorted by date in descending order when it is loaded.  I have copied the function here:

            loadComplete: function() {
                if (jQuery(grid).jqGrid('getGridParam', 'records') == 0) {
                    // #divsearchtab').tabs
                   
                    $("#divsearchtab").tabs("disable", tabid-1);
                }
            $("#divsearchresults").append(returnSearchResults("Q&R", jQuery(grid).jqGrid('getGridParam', 'records')));
            },
            colNames: ['ID', 'Title', 'Forum', 'Category', 'Date', 'EmailAddress', 'Author'],
            colModel: [
                   { name: 'ID', index: ID', width: 5, sortable: true, hidden: true },
                      { name: 'SubjectText', index:'SubjectText', width: 300 ,sortable: true},
                       { name: 'DiscForumName', index:'DiscForumName',width: 150 ,sortable: true},
                        { name: 'CategoryName',index:'CategoryName', width: 200, sortable: true },

                       { name: 'AskedWhen', index:'AskedWhen', width: 160, align:'center', sorttype:'date', formatter: 'date', formatoptions: {srcformat: "d-m-Y H:i:s", newformat: "Y-M-d H:i:s"}},
                        { name: 'EmailAddress', width: 100, hidden: true },
                         { name: 'Author', width: 100, hidden: true }
                 ],
            rowNum: 50, height: 350,
            rowList: [20, 30, 50, 100, 500],
            pager: pager,
            sortname: 'AskedWhen',
            //sorttype: 'date',
            //loadonce: true,
            viewrecords: true,
            sortorder: "desc",
            caption: search
        });
        jQuery(grid).jqGrid('navGrid', pager, { del: false, add: false, edit: false });

    });

I also have to format the date column to a specific format. Also, can someone please explain to me what srcformat means and newformat means?

I have also supplied some of the JSON data that is usded for this grid from firebug:

cell ["25", "Example Measurement", "iceForum", 4 more...]
0 "25"
1 "Example Measurement"
2 "iceForum"
3 "30 - Instruments and Control"
4 "08/06/2002 16:15:59"
5 "test@mail.com"
6 "Mark Smith"
id "25"

if anyone can help me then that would be great!

Cheers,

-BIZ-
0
Comment
Question by:-BIZ-
1 Comment
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36524883
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month18 days, 23 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question