Search code examples
javascriptdatejqgrid

Sort date column dd/mm/yyyy fromat Jqgrid


I have a jqgrid grid and it has a date table. The date is in dd/mm/yyyy format. I want to sort the column by clicking colomn header. I use sorttype : 'date',formatter:'date', datefmt: 'd/m/Y' on my column properties. But after using this formatting the date data is changed and they are wired. Can anyone help me to sort date column?


Solution

  • The reason is in the small misunderstanding of the meaning of datefmt option. It will be used only if you use sorttype: "date" (or sorttype: "datetime") without formatter: "date". On the other side if you use formatter: "date" you should specify formatoptions with srcformat and newformat. So you should either remove formatter: "date" or add formatoptions: { srcformat: "d/m/Y", newformat: "d/m/Y" }. If the input data are already in the format d/m/Y which you already use to display the data it's more logically in my opinion just to remove unneeded formatter: "date".