Filter events by name to find planning sessions, meetings or other items in a busy month. Client-side filtering works with events that have already been loaded; it does not request new data from the server.
How Event Filtering Works
- Register an
onEventFilterhandler to define the matching rule. It receives the event asargs.eand your criteria asargs.filter. Theargs.visiblevalue starts astrue; set it tofalseto hide an event that does not match. - Call
events.filter()on the Month control to apply your criteria, for exampledp.events.filter("plan"). Month redraws the calendar using your handler's matching logic, such as a search of the event text. - Call
dp.events.filter(null)to clear the filter and restore normal event visibility.
Filtering changes visibility without removing events from events.list. You can pass a string or an object containing several criteria; the same value is available as args.filter in the handler.
These examples match part of an event's name, ignoring case and leading or trailing spaces. Entering plan shows Release planning, Sprint planning and Planning review. Clear the search to show all loaded events again. A search with no matches leaves the grid empty.

plan displays the three matching events.Example Data
Save this shared data as events.js for JavaScript or events.ts for the TypeScript framework examples. Event end dates are exclusive.
export const events = [
{id: 1, text: "Release planning", start: "2028-11-06", end: "2028-11-08"},
{id: 2, text: "Design review", start: "2028-11-08", end: "2028-11-09"},
{id: 3, text: "Sprint planning", start: "2028-11-13", end: "2028-11-15"},
{id: 4, text: "Team meeting", start: "2028-11-15", end: "2028-11-16"},
{id: 5, text: "Client demo", start: "2028-11-20", end: "2028-11-21"},
{id: 6, text: "Planning review", start: "2028-11-22", end: "2028-11-24"}
];JavaScript
After loading the DayPilot Pro JavaScript library, register the matching handler in the Month configuration. The input listener normalizes the query and calls dp.events.filter(query || null) whenever the search changes.
<label for="filter">Filter events:</label>
<input id="filter" type="search" placeholder="Event name">
<button id="clear" type="button">Clear</button>
<div id="dp"></div>
<script type="module">
import {events} from "./events.js";
const dp = new DayPilot.Month("dp", {
startDate: "2028-11-01",
weekStarts: 1,
events,
onEventFilter: args => {
args.visible = args.e.text().toLowerCase().includes(args.filter);
}
});
dp.init();
const input = document.querySelector("#filter");
input.addEventListener("input", () => {
const query = input.value.trim().toLowerCase();
dp.events.filter(query || null);
});
document.querySelector("#clear").addEventListener("click", () => {
input.value = "";
dp.events.filter(null);
});
</script>The native input event also covers pasted text and the search field's built-in clear action. An empty or whitespace-only query clears the filter.
Framework Examples
The framework examples use the same onEventFilter handler and events.filter() method. Each component keeps the full event dataset; filtering changes which events are visible.
These examples use DayPilot Pro. For installation, see the Angular Month, React Month and Vue Month guides.
Angular
import {Component, ViewChild} from "@angular/core";
import {DayPilot, DayPilotModule, DayPilotMonthComponent} from "daypilot-pro-angular";
import {events} from "./events";
@Component({
selector: "app-month-filter",
standalone: true,
imports: [DayPilotModule],
template: `
<label for="filter">Filter events:</label>
<input #search id="filter" type="search" placeholder="Event name"
[value]="query" (input)="filterEvents(search.value)">
<button type="button" (click)="filterEvents('')">Clear</button>
<daypilot-month #month
[config]="config"
[events]="events"></daypilot-month>
`
})
export class MonthFilterComponent {
@ViewChild("month") month!: DayPilotMonthComponent;
query = "";
events = events;
config: DayPilot.MonthConfig = {
startDate: "2028-11-01",
weekStarts: 1,
onEventFilter: args => {
args.visible = args.e.text().toLowerCase().includes(args.filter);
}
};
filterEvents(text: string) {
this.query = text;
const query = text.trim().toLowerCase();
this.month.control.events.filter(query || null);
}
}Use the DayPilotMonthComponent reference to call this.month.control.events.filter().
React
import {useEffect, useState} from "react";
import {DayPilot, DayPilotMonth} from "daypilot-pro-react";
import {events} from "./events";
export default function MonthFilter() {
const [query, setQuery] = useState("");
const [month, setMonth] = useState<DayPilot.Month | null>(null);
useEffect(() => {
if (!month) { return; }
month.events.filter(query.trim().toLowerCase() || null);
}, [month, query]);
return <>
<label htmlFor="filter">Filter events:</label>
<input id="filter" type="search" placeholder="Event name" value={query}
onChange={event => setQuery(event.target.value)} />
<button type="button" onClick={() => setQuery("")}>Clear</button>
<DayPilotMonth
startDate="2028-11-01"
weekStarts={1}
events={events}
controlRef={setMonth}
onEventFilter={args => {
args.visible = args.e.text().toLowerCase().includes(args.filter);
}}
/>
</>;
}controlRef provides the Month instance. The effect applies the current query after that instance becomes available and whenever the query changes.
Vue
<script setup lang="ts">
import {ref, watch} from "vue";
import {DayPilot, DayPilotMonth} from "daypilot-pro-vue";
import {events} from "./events";
const query = ref("");
const month = ref<DayPilotMonth | null>(null);
function onEventFilter(args: DayPilot.MonthEventFilterArgs) {
args.visible = args.e.text().toLowerCase().includes(args.filter);
}
watch(query, text => {
month.value?.control.events.filter(text.trim().toLowerCase() || null);
});
</script>
<template>
<label for="filter">Filter events:</label>
<input id="filter" type="search" placeholder="Event name" v-model="query">
<button type="button" @click="query = ''">Clear</button>
<DayPilotMonth
ref="month"
startDate="2028-11-01"
:weekStarts="1"
:events="events"
:onEventFilter="onEventFilter"
/>
</template>The component ref exposes the Month instance as month.value.control.
Filter by Other Fields
Your matching rule can also read custom event data, such as a project or status. Pass an object to events.filter() and read its fields from args.filter in onEventFilter.
If the server should select the records, send the criteria to your own endpoint and load the returned events.
ASP.NET WebForms
Use ClientState to persist the filter parameters.
You can store the filter settings in .clientState property on the client side:
dpm.clientState.filterText = 'text';
dpm.clientState.filterType = 'finished';ClientState is persisted and updated with every callback (until you reload the page) and it's accessible on the server side.
string filterText = (string) DayPilotMonth1.ClientState["filterText"];
string filterType = (string) DayPilotMonth1.ClientState["filterType"];
DayPilotMonth1.DataSource = LoadData(filterText, filterType);
DayPilotMonth1.DataBind();
DayPilotMonth1.Update();ASP.NET MVC
Use ClientState to persist the filter parameters.
You can store the filter settings in .clientState property on the client side:
dpm.clientState.filterText = 'text';
dpm.clientState.filterType = 'finished';ClientState is persisted and updated with every callback (until you reload the page) and it's accessible on the server side.
string filterText = (string) ClientState["filterText"];
string filterType = (string) ClientState["filterType"];
Events = LoadEvents(filterText, filterType);
Update();Availability
Availability of this feature in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript | ||
| DayPilot for ASP.NET WebForms | ||
| DayPilot for ASP.NET MVC | ||
| DayPilot for Java |
DayPilot