1

I have jqGrid 4.15.3. I am using filterToolbar for search in columns. I have column with date, which comes in following format "/Date(1515401700270)/". The compare parameters are eq,ge. The problem is that ge is working properly, but when searching with equal with existing value in the grid, it does not display anything. Do you have any ideas how to resolve this ? Is this connected with srcFormat of the model ?

Value: /Date(1515401700270)/ -> does not work
Value: 2017-01-02 -> work

The column model which I am using is:

{ "search" : "true", "label" : "DateCreated", "name": "DateCreated", "width" : 140, "sorttype": "date", "formatter" : "date", "formatoptions" : { "newformat" : "d.m.Y" },  
"searchoptions" : { "clearSearch" : "false",  "sopt": ["eq","ge"], "dataInit" : "(function(el) { $(el).datepicker( { firstDay: 1, dateFormat: 'dd.mm.yy' } ); })  " } }]
theChampion
  • 4,207
  • 7
  • 28
  • 35

1 Answers1

0

The reason of the problem very easy to explain. Date(1515401700270) is really not 2018-01-08, but it's 2018-01-08 09:55:00 GMT+0100" instead. Even is you shows full date as the date rounded till the days only jqGrid still holds the data as original date. During comparing of dates the original dates will be used.

To allow the users to use "Equal" operations on such dates you have three main options:

  1. you change your server code to set the time of all dates to 00:00
  2. you add jsonmap property in the column DateCreated to round the input values to the date with 00:00 as time. jsonmap are used to read the input data and the data saved in jqGrid locally will be rounded
  3. you can define custom sorting/filtering operation by adding customSortOperations. It allows to redefine eq operation of your dates. You will need just to define eq so that it compares only year, month and day and ignore all other . You can see the description of the feature in the wiki article. The answer includes the demo, which demonstrates the approach.
Oleg
  • 220,925
  • 34
  • 403
  • 798