look_right
look_right

Reputation: 33

Sorting jqGrid by one value, when showing another value in the cell?

A situation:

$("#CreditLineEditorContent #tabs #PmntDates").jqGrid({
    datatype: "local",
    height: 250,
    colNames: ["Date", "In", "Out"],
    colModel: [
        { name: 'pmntDate', index: 'pmntDate', width: 150, sorttype: "date", sortable:false },
        { name: 'incSum', index: 'incSum', width: 150, sorttype: "float", formatter: 'currency' },
        { name: 'decSum', index: 'decSum', width: 150, sorttype: "float", formatter: 'currency' }
});

I need to sort my grid by column "Date".
The problem is following: I have a pmntDate as a String (e. g. 02.09.2013), so it sorted as a String, not Date

So, the question is:
How can I show a String values (e. g. 02.09.2013) but sort by original values (Date)?

Upvotes: 1

Views: 98

Answers (2)

look_right
look_right

Reputation: 33

Thanks a lot. The right answer:

... sorttype: "date", formatter: 'date', formatoptions: { srcformat: 'ISO8601Long', newformat: 'd.m.Y' } }

Upvotes: 0

Nikolai Saiko
Nikolai Saiko

Reputation: 1728

Try datefmt option:

{ name: 'pmntDate', ..., sorttype: "date", sortable:true, datefmt: "dd.mm.yyyy" }

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options

Upvotes: 1

Related Questions