DayPilot.Gantt.rows.filter

The rows.filter() method filters JavaScript Gantt Chart component tasks using the specified parameter.

Available since 2022.4.5452.

Declaration

DayPilot.Gantt.rows.filter(params)

Arguments

  • params - custom object (or a simple string value) that will be passed to onRowFilter event as args.filterParam.

See Also

Example

<div class="space">
    Filter: <input id="filter"/> <a href="#" id="clear">Clear</a>
</div>

<div id="dp"></div>

<script type="text/javascript">

    const dp = new DayPilot.Gantt("dp", {
      onRowFilter: (args) => {
          const query = args.filterParam.query;

          if (!args.task.data.text.toUpperCase().includes(query.toUpperCase())) {
              args.visible = false;
          }

      }    
    });
    dp.init();

    const app = {
        elements: {
            filter: document.querySelector("#filter"),
            clear: document.querySelector("#clear")
        },
        init() {
            const elements = app.elements;
            elements.filter.addEventListener("keyup", function() {
                app.filter();
            });

            elements.clear.addEventListener("click", function(ev) {
                ev.preventDefault();
                elements.filter.value = "";
                app.filter();
            });
        },
        filter() {
            // filter is applied using onTaskFilter event handler
            dp.rows.filter({
                query: app.elements.filter.value
            });
        }
    };

    app.init();


</script>