Hello @Skumar ,
Regarding this part:
The chart by default is showing as blank and only when clicked on any filter button, I am seeing the output. Could you please let me know how to resolve this error
Highly likely it occurs because the filter function fires on the first loading of the chart, but as there is no selected date range - all tasks are filtered as non-allowed.
So, if there is no value in the filtering function, you can return true
by default, so all tasks will be displayed, it may look like follows:
function compare_input(id) {
var match = false;
var currYear = new Date().getYear();
if(!val){
return true;
}
if(val == 1){
searchedYear = --currYear
}
Regarding this part:
I am using a search box filter where users will be filtering out the tasks. But, when I have updated the logic with these filter buttons, I could see that the search filter is not responding.
Below is the logic related to it:
HTML:
<input type="text" name="a12" value="" id="a12" oninput='gantt.$doFilter(this.value)' style="width: 100px;"/>
JS:
var filterValue = “”;
var delay;
gantt.$doFilter = function(value){
filterValue = value;
clearTimeout(delay);
delay = setTimeout(function(){
gantt.render();
gantt.$root.querySelector("[data-text-filter]").focus();
}, 200)
};
gantt.attachEvent("onBeforeTaskDisplay", function (id, task) {
if(!filterValue){
return true;
}
var normalizedText = task.text.toLowerCase();
var normalizedValue = filterValue.toLowerCase();
return normalizedText.indexOf(normalizedValue) > -1;
if (compare_input(id)) {
return true;
}
return false;
});
I could see that the issue is coming from gantt.attachEvent function where we are returning both search box filter and date filter. Could you please let me know how to resolve this error.
I tried to reproduce the described issue with the provided code, just commented the follows line :
gantt.$root.querySelector("[data-text-filter]").focus();
But the filtering worked correctly, here is the snippet I tried:
http://snippet.dhtmlx.com/5/502708a4f
It’s hard to suggest why it works wrong in your case, so could you please reproduce the issue in the snippet above(open the snippet => reproduce the issue on HTML/CODE tabs => click the “Share” button => send me the new link)?
Regarding this part:
And as the last query, could you please let me know if there is any way that I can display the filters in a single dropdown view instead of individual buttons.
The buttons are created just for demo purposes, and you can use any control that you require. In case of dropdown - you have to create a select
element, with the onChange
listener:
<select onchange="myFunction()">
and call the filtering function(with different parameters) for different options.
Kind regards,