Filter gantt based on date


I was able to follow a tutorial and add a search bar as a filter.
Now, I would like to add a filter based on dates that the user will input. I added html to input the dates, I would like to grab the dates and used them to filter my gantt.

    <label for="startDate">Start date</label>
    <input type="date" class="k-textbox" id="startDate" />
    <label for="endDate">End date</label>
    <input type="date" class="k-textbox" id="endDate" />
    <button type="button" id="filterSort">Set Filters</button>


Hi @secla,
In order to implement the date filtering, you should do a few steps:

  1. Create HTML inputs to print the data range, like in the code fragment from your post.

  2. Get the HTML input’s through the js to be able to get their values, like in this code fragment:

gantt.attachEvent("onDataRender", function(){
start_search_box = document.getElementById("search_start");
end_search_box = document.getElementById("search_end");
  1. After that, you will be able to get their values, but to compare it with the task’s dates you should convert their format from the “string” to “date” format.
    The gantt built-in solution to do it is the method, which converts a string to the date, this method expects string in the specific format, you can read about this by the following link:

  2. After that, you will be able to compare the task’s date with the converted input’s value, like in this fragment:

function compare_input(id) {
  var match = false; 
    if (gantt.getTask(id).start_date >= strToDate(start_filter_data) && gantt.getTask(id).end_date <= strToDate(end_filter_data))
      match = true;
return match;
  1. And the last step is to use this “compare” function, to choose which tasks should be displayed or not. The built-in gantt solution for this is the “onBeforTaskDisplay” event, here is a link:

Here is an example of how the date filtering could be implemented(click the filter button):

Add search field for both Start Date and Duration columns

thank you. it helped me.