Resource Search and Filtering

When dealing with numerous resources, filtering and search are essential tools. Using the resourceHeaderTemplate option you can customize the resource header and fit a search input and filter button. Having full control over what you render in the resource header, you can implement live search and filering with a flyout, allowing users to quickly locate specific resources based on selected filters.

To handle cases where no search results are found, use the resourceEmptyTemplate option to craft a custom placeholder with specific call-to-action buttons eg. clearing all search terms and resetting filters. The placeholder appears when an empty resource array is passed to the calendar.

Get started with this example

Demo

Loading the live demo

Preview in full screen

Add live search and filter to a Timeline resource header — multi-select by status or group, with a custom empty state and reset.

Code

import { CommonModule } from '@angular/common';
import { Component, ElementRef, ViewChild } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
  MbscCalendarEvent,
  MbscEventcalendarOptions,
  MbscModule,
  MbscPopup,
  MbscPopupButton,
  MbscPopupOptions,
  MbscResource,
  Notifications,
  setOptions ,
} from '@mobiscroll/angular';

setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
});

@Component({
  selector: 'app-root', 
  templateUrl: './app.component.html',
  providers: [Notifications],
  standalone: true,
  imports: [CommonModule, FormsModule, MbscModule],
})
export class AppComponent {
  constructor(private notify: Notifications) {
    this.myResources.forEach((site) => {
      this.myFilters.push({ id: site.id as string, name: site.name as string, value: true });
    });

    this.filters = this.myFilters.reduce<Record<string, boolean>>((map, filter) => {
      map[filter.id] = true;
      return map;
    }, {});
  }

  myEvents: MbscCalendarEvent[] = [
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T19:00',
      title: 'Excavate Foundation',
      resource: 'bulldozer - TX1234',
    },
    {
      start: '2026-10-25T08:00',
      end: '2026-10-25T18:00',
      title: 'Install Framing',
      resource: 'crane - NY9101',
    },
    {
      start: '2026-10-25T07:00',
      end: '2026-10-25T20:00',
      title: 'Electrical Wiring',
      resource: 'excavator - FL1213',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T22:00',
      title: 'Roofing',
      resource: 'crane - IL1617',
    },
    {
      start: '2026-10-25T07:00',
      end: '2026-10-25T19:00',
      title: 'Site Cleanup',
      resource: 'bulldozer - PA1819',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T18:00',
      title: 'Foundation Work',
      resource: 'concrete mixer - CA2223',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T22:00',
      title: 'Steel Framing',
      resource: 'crane - NY2425',
    },
    {
      start: '2026-10-25T07:00',
      end: '2026-10-25T16:00',
      title: 'Interior Plumbing',
      resource: 'excavator - FL2627',
    },
    {
      start: '2026-10-25T07:00',
      end: '2026-10-25T16:00',
      title: 'Masonry Work',
      resource: 'crane - IL3031',
    },
    {
      start: '2026-10-25T06:00',
      end: '2026-10-25T15:00',
      title: 'Exterior Work',
      resource: 'bulldozer - PA3233',
    },
    {
      start: '2026-10-25T06:00',
      end: '2026-10-25T15:00',
      title: 'Ground Breaking',
      resource: 'bulldozer - TX3435',
    },
    {
      start: '2026-10-25T09:00',
      end: '2026-10-25T21:00',
      title: 'Wall Construction',
      resource: 'crane - NY3839',
    },
    {
      start: '2026-10-25T07:00',
      end: '2026-10-25T16:00',
      title: 'Roof Installation',
      resource: 'excavator - FL4041',
    },
    {
      start: '2026-10-25T06:00',
      end: '2026-10-25T19:00',
      title: 'Painting',
      resource: 'crane - IL4445',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T20:00',
      title: 'Driveway Paving',
      resource: 'bulldozer - PA4647',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T18:00',
      title: 'Foundation',
      resource: 'concrete mixer - CA5051',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T19:00',
      title: 'Demolition',
      resource: 'crane - NY5253',
    },
    {
      start: '2026-10-25T06:00',
      end: '2026-10-25T16:00',
      title: 'Electrical Wiring',
      resource: 'excavator - FL5455',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T17:00',
      title: 'Roofing',
      resource: 'crane - IL5859',
    },
    {
      start: '2026-10-25T08:00',
      end: '2026-10-25T18:00',
      title: 'Finishing Touches',
      resource: 'bulldozer - PA6061',
    },
    {
      start: '2026-10-25T12:00',
      end: '2026-10-25T22:00',
      title: 'Site Preparation',
      resource: 'bulldozer - TX6263',
    },
    {
      start: '2026-10-25T08:00',
      end: '2026-10-25T19:00',
      title: 'Piling Work',
      resource: 'crane - NY6667',
    },
    {
      start: '2026-10-25T07:00',
      end: '2026-10-25T18:00',
      title: 'Concrete Pouring',
      resource: 'excavator - FL6869',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T21:00',
      title: 'Deck Construction',
      resource: 'drill - OH7071',
    },
    {
      start: '2026-10-25T05:00',
      end: '2026-10-25T20:00',
      title: 'Final Touches',
      resource: 'bulldozer - PA7475',
    }, // Showing partial data. Download full source.
  ];

  myResources: MbscResource[] = [
    {
      id: 'site1',
      name: '123 Main St, Downtown City',
      eventCreation: false,
      children: [
        {
          id: 'bulldozer - TX1234',
          name: 'Bulldozer - TX1234',
          color: '#1dab2f',
          status: 'on site',
        },
        {
          id: 'concrete mixer - CA5678',
          name: 'Concrete Mixer - CA5678',
          color: '#1dab2f',
          status: 'in maintenance',
        },
        {
          id: 'crane - NY9101',
          name: 'Crane - NY9101',
          color: '#1dab2f',
          status: 'on site',
        },
        {
          id: 'excavator - FL1213',
          name: 'Excavator - FL1213',
          color: '#1dab2f',
          status: 'on site',
        },
        {
          id: 'drill - OH1415',
          name: 'Drill - OH1415',
          color: '#1dab2f',
          status: 'in maintenance',
        },
        {
          id: 'crane - IL1617',
          name: 'Crane - IL1617',
          color: '#1dab2f',
          status: 'on site',
        },
        {
          id: 'bulldozer - PA1819',
          name: 'Bulldozer - PA1819',
          color: '#1dab2f',
          status: 'on site',
        },
      ],
    },
    {
      id: 'site2',
      name: '456 Elm St, Uptown City',
      eventCreation: false,
      children: [
        {
          id: 'bulldozer - TX2021',
          name: 'Bulldozer - TX2021',
          color: '#4981d6',
          status: 'in maintenance',
        },
        {
          id: 'concrete mixer - CA2223',
          name: 'Concrete Mixer - CA2223',
          color: '#4981d6',
          status: 'on site',
        },
        {
          id: 'crane - NY2425',
          name: 'Crane - NY2425',
          color: '#4981d6',
          status: 'on site',
        },
        {
          id: 'excavator - FL2627',
          name: 'Excavator - FL2627',
          color: '#4981d6',
          status: 'on site',
        },
        {
          id: 'drill - OH2829',
          name: 'Drill - OH2829',
          color: '#4981d6',
          status: 'in maintenance',
        },
        {
          id: 'crane - IL3031',
          name: 'Crane - IL3031',
          color: '#4981d6',
          status: 'on site',
        },
        {
          id: 'bulldozer - PA3233',
          name: 'Bulldozer - PA3233',
          color: '#4981d6',
          status: 'on site',
        },
      ],
    },
    {
      id: 'site3',
      name: '789 Maple Ave, Suburban Area',
      eventCreation: false,
      children: [
        {
          id: 'bulldozer - TX3435',
          name: 'Bulldozer - TX3435',
          color: '#f7961e',
          status: 'on site',
        },
        {
          id: 'concrete mixer - CA3637',
          name: 'Concrete Mixer - CA3637',
          color: '#f7961e',
          status: 'in maintenance',
        },
        {
          id: 'crane - NY3839',
          name: 'Crane - NY3839',
          color: '#f7961e',
          status: 'on site',
        },
        {
          id: 'excavator - FL4041',
          name: 'Excavator - FL4041',
          color: '#f7961e',
          status: 'on site',
        },
        {
          id: 'crane - IL4445',
          name: 'Crane - IL4445',
          color: '#f7961e',
          status: 'on site',
        },
        {
          id: 'bulldozer - PA4647',
          name: 'Bulldozer - PA4647',
          color: '#f7961e',
          status: 'on site',
        },
      ],
    },
    {
      id: 'site4',
      name: '101 Industrial Blvd, Industrial City',
      eventCreation: false,
      children: [
        {
          id: 'bulldozer - TX4849',
          name: 'Bulldozer - TX4849',
          color: '#e25dd2',
          status: 'in maintenance',
        },
        {
          id: 'concrete mixer - CA5051',
          name: 'Concrete Mixer - CA5051',
          color: '#e25dd2',
          status: 'on site',
        },
        {
          id: 'crane - NY5253',
          name: 'Crane - NY5253',
          color: '#e25dd2',
          status: 'on site',
        },
        {
          id: 'excavator - FL5455',
          name: 'Excavator - FL5455',
          color: '#e25dd2',
          status: 'on site',
        },
        {
          id: 'drill - OH5657',
          name: 'Drill - OH5657',
          color: '#e25dd2',
          status: 'in maintenance',
        },
        {
          id: 'crane - IL5859',
          name: 'Crane - IL5859',
          color: '#e25dd2',
          status: 'on site',
        },
        {
          id: 'bulldozer - PA6061',
          name: 'Bulldozer - PA6061',
          color: '#e25dd2',
          status: 'on site',
        },
      ],
    },
    {
      id: 'site5',
      name: '202 River Rd, Riverside City',
      eventCreation: false,
      children: [
        {
          id: 'bulldozer - TX6263',
          name: 'Bulldozer - TX6263',
          color: '#34c8e0',
          status: 'on site',
        },
        {
          id: 'concrete mixer - CA6465',
          name: 'Concrete Mixer - CA6465',
          color: '#34c8e0',
          status: 'in maintenance',
        },
        {
          id: 'crane - NY6667',
          name: 'Crane - NY6667',
          color: '#34c8e0',
          status: 'on site',
        },
        {
          id: 'excavator - FL6869',
          name: 'Excavator - FL6869',
          color: '#34c8e0',
          status: 'on site',
        },
        {
          id: 'drill - OH7071',
          name: 'Drill - OH7071',
          color: '#34c8e0',
          status: 'on site',
        },
        {
          id: 'crane - IL7273',
          name: 'Crane - IL7273',
          color: '#34c8e0',
          status: 'in maintenance',
        },
        {
          id: 'bulldozer - PA7475',
          name: 'Bulldozer - PA7475',
          color: '#34c8e0',
          status: 'on site',
        },
      ],
    },
  ];

  myFilters: { id: string; name: string; value: boolean }[] = [
    { id: 'on site', name: 'On site', value: true },
    { id: 'in maintenance', name: 'In maintenance', value: true },
  ];

  @ViewChild('popup', { static: false })
  popup!: MbscPopup;

  @ViewChild('filterButton') anchorElm!: ElementRef;
  popupAnchor!: HTMLButtonElement;
  filteredResources: MbscResource[] = this.myResources;
  searchQuery = '';
  filters: Record<string, boolean> = {};
  tempFilters: Record<string, boolean> = {};
  searchTimeout: ReturnType<typeof setTimeout> | undefined;

  filterResources(currentFilters: Record<string, boolean>, currentQuery: string) {
    this.filteredResources = this.myResources
      .map((site) => ({
        id: site.id,
        name: site.name,
        eventCreation: site.eventCreation,
        children: (site.children ?? []).filter(
          (resource) =>
            currentFilters[resource['status']] &&
            (!currentQuery || (resource.name && resource.name.toLowerCase().includes(currentQuery.toLowerCase()))),
        ),
      }))
      .filter((site) => site.children.length > 0 && currentFilters[site.id]);
  }

  openFilters() {
    this.popupAnchor = this.anchorElm.nativeElement;
    this.tempFilters = { ...this.filters };
    this.popup.open();
    this.filterResources(this.tempFilters, this.searchQuery);
  }

  applyFilters() {
    this.filters = { ...this.tempFilters };
    this.filterResources(this.tempFilters, this.searchQuery);
    this.popup.close();
    this.notify.toast({
      message: 'Filters applied',
    });
  }

  resetFilters() {
    const updatedFilters = this.myFilters.reduce<Record<string, boolean>>((map, filter) => {
      map[filter.id] = true;
      return map;
    }, {});
    this.searchQuery = '';
    this.filters = { ...updatedFilters };
    this.filterResources(updatedFilters, '');
    this.notify.toast({
      message: 'Filters cleared',
    });
  }

  handleSearch() {
    clearTimeout(this.searchTimeout);
    this.searchTimeout = setTimeout(() => {
      this.filterResources(this.filters, this.searchQuery);
    }, 300);
  }

  handleCheckboxChange(key: string) {
    this.tempFilters[key] = !this.tempFilters[key];
    this.tempFilters = { ...this.tempFilters };
  }

  calendarOptions: MbscEventcalendarOptions = {
    cssClass: 'mds-resource-filtering-calendar',
    clickToCreate: true,
    dragToCreate: true,
    dragToMove: true,
    dragToResize: true,
    view: {
      timeline: {
        type: 'week',
        startTime: '05:00',
        endTime: '22:00',
        startDay: 1,
        endDay: 5,
        timeCellStep: 60,
        timeLabelStep: 60,
        weekNumbers: true,
      },
    },
  };

  popupOptions: MbscPopupOptions = {
    display: 'anchored',
    contentPadding: false,
    focusOnClose: false,
    focusOnOpen: false,
    showOverlay: false,
    width: 400,
  };

  popupButtons: (MbscPopupButton | 'cancel')[] = [
    'cancel',
    {
      handler: () => {
        this.applyFilters();
      },
      keyCode: 'enter',
      text: 'Apply',
      cssClass: 'mbsc-popup-button-primary',
    },
  ];
}

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.