Translate

Friday, May 11, 2012

jQGrid and Date

jQgrid fails to sort or search Date columns correctly if you don't set proper format on the Date field. I finally corrected my problem by setting Date format before converting the object into JSON.

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = formatter.format(date);
object.setDate(formattedDate);

Properties set in the grid was as below:


{
  name:'myDateField',
  index:' myDateField ',
  sortable:true,
sorttype:'date',
formatter:'date'
 }

No comments:

Post a Comment