Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQgrid Sorting date on the client side with a specific format

I am using JQGrid to store the data which is being loaded on the client side itself. I want sort the date which is in a customized format(i.e. 11-Nov-2010). I want to sort it on the client side (due to the requirement). Can anyone of you suggest me what I need to do?

Thanks in Advance!

With Regards

Phani Kumar

like image 686
Patton Avatar asked Dec 28 '10 07:12

Patton


1 Answers

jqGrid support date formatter. It allows to display the date in the grid in the format which you prefer. You need only the choose the corresponding formatter option like

sorttype:'date', formatter:'date', formatoptions: {newformat:'d-M-Y'}

So you can fill the grid in one format (default format form is ISO Date format Y-m-d and I recommend you to use this format). You can also use Date type as input for the local data. The option newformat define the format of data which will be displayed for the user. Internally the date will be hold and sorted as the Date JavaScript type.

To make easy to use practically what I explained above I created small demo example which you can see live and examin it's JavaScript code.

like image 171
Oleg Avatar answered Nov 17 '22 04:11

Oleg