Closed gestinronan closed 8 years ago
Hi,
This feature also interested me !!! I try several weeks ago to achieve, but without success.
My only solution today is to cheat by adding hidden columns Days, Month and Year, and play with 6 filter field :( :( :(.
But the solution is not really ergonomic (and very dirty :-1: )
A simple assumption of a field with a time picker would be perfect if it could exist
Is that possible? how to realize it?
Thank you in advance,
cordially
@gestinronan, I don't understand what is the exact problem, can you please give me more information? if you defined a custom filter view, containing two input elements for a date range:
<label for="start-date">Start date</label>
<input id="start-date" type="text" class="datepicker" name="start-date" />
<label for="end-date">End date</label>
<input id="end-date" type="text" class="datepicker" name="end-date" />
And filters implementation (for client side filtering), like described in this wiki page,
$("#content").kingtable({
id: "my-table",
filtersView: "custom-filters",//can be the id of an element;
filters: {
//NB: the keys of filters object must match the name property of input elements
//that are defined in the filters view
"start-date": function (filter, obj) {
// implement here your logic: the filter is the value in the input field (to be parsed into a date)
// obj is a single item in your table
// return true if the object should be filtered, false otherwise
},
"end-date": function (filter, obj) {
// implement here your logic: the filter is the value in the input field (to be parsed into a date)
// obj is a single item in your table
// return true if the object should be filtered, false otherwise
},
You should be able to filter elements using a date range. Consider that: in the above example the value of the input fields must be parsed and validated by you. I am going to prepare an example that integrates the jQuery DatePicker, to make this process easier.
@clicitra you are absolutely right: in the current implementation it's not easy to integrate a datepicker in the custom filters view. I will improve the library to allow for easy integration with jQuery DatePicker (or any other library that provides this feature), and prepare a working example for you.
I will do it soon and let you know when it's ready.
@gestinronan, @clicitra I kept my word: I improved the library to support datepickers easily, and to allow the string search inside date strings.
A working demo is available here. If you pull the latest changes from the repository, you will be able to run the included Flask development server and see the working demo with ajax requests (page /datetime-filters.html).
However, keep in mind that:
Closing the issue, since I didn't receive any feedback.
I'm going to test this right now
hello,
i would like to filters my table on an interval into two date . but custom filters i try to compare date does not works. have you an idea to do this things?
thx