I currently have an issue where I have datetime columns in a grid that are formatted to only display the date portion of the field. So the raw data looks like "2015-04-15T15:31:49.357" and the grid column looks like "4/15/2015".
I am using a datepicker to support column filtering and would like to be able to use the "eq" operator to filter using "equals" but just on the date portion. Currently I do not get any matches because the time is getting in the way.
Is it possible to get around this? I know I can manipulate the raw data to strip off the time portion of the date, but I would prefer to keep that information in the raw data since I also support exporting to excel and the time might be needed.
My current options for the column are:
formatter = "date";
formatoptions = {srcformat: "Y-m-d", newformat: "n/j/Y"};
I have tried various options but so far have not had any luck.
I am also using the free-jqgrid fork.
Response from OlegKi on github: https://github.com/free-jqgrid/jqGrid/issues/50
I introduced custom filtering feature in free jqGrid to allow easy implements the scenarios like youth. The answer provide an example of such implementation.
In your case one can define new Date only \"equal\"compare operation under the short name "deq" for example and the compare operation Date only "not equal" under the short name dne. The code of customSortOperations option could be the following:
} To be able to use new "deq" and "dne" operation you should include there in sopt of searchoptions of the column with the date.
The demo uses the above code. The input data contains 3 dates: "2015-04-15T15:31:49.357", "2015-04-15T21:15:40.123", "2015-04-15". The filtering by 15-Apr-2015 display all the three rows.
Another demo uses practically the same code, but displays the date in full date/time format. Nevertheless the filtering works. Be carefully, that I use the latest free jqGrid sources from GitHub in the demo. It's really needed because I made some small changes in the code of parseDate to make the demo working.
I introduced custom filtering feature in free jqGrid to allow easy implements the scenarios like youth. The answer provide an example of such implementation.
In your case one can define new
Date only "equal"
compare operation under the short name"deq"
for example and the compare operationDate only "not equal"
under the short namedne
. The code ofcustomSortOperations
option could be the following:To be able to use new
"deq"
and"dne"
operation you should include there insopt
ofsearchoptions
of the column with the date.The demo uses the above code. The input data contains 3 dates:
"2015-04-15T15:31:49.357"
,"2015-04-15T21:15:40.123"
,"2015-04-15"
:The filtering by
15-Apr-2015
display all the three rows:Another demo uses practically the same code, but displays the date in full date/time format. Nevertheless the filtering works. Be carefully, that I use the latest free jqGrid sources from GitHub in the demo. It's really needed because I made some small changes in the code of
parseDate
to make the demo working.