Solved

Can't sort by date on jqgrid

Posted on 2011-09-12
1
1,201 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-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36524883
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

738 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