Scheduler has API to exclude some of the Time Scales from the View

React Scheduler: Time Scales Configuration

Time scales configuration in React Scheduler.

A live React example of jqxScheduler, the jQWidgets Scheduler component, with its complete source code below. It is one of 44 jqxScheduler demos for React.

jqxScheduler API used in this demo

Source code

To run it in your own app, install the package with npm install jqwidgets-scripts, add these files to a Vite React and TypeScript project, and import jqx.base.css and a theme in main.tsx. Getting started with jqxScheduler shows the setup step by step.

App.tsx

import type { JSX } from 'react';
import { useRef, useMemo } from 'react';
import JqxScheduler, { type ISchedulerProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxscheduler';

interface Appointment {
  id: string;
  status: string;
  about: string;
  address: string;
  company: string;
  name: string;
  style: string;
  calendar: string;
  start: Date | string;
  end: Date | string;
}

interface AppointmentDataFields {
  description: keyof Appointment;
  from: keyof Appointment;
  id: keyof Appointment;
  location: keyof Appointment;
  resourceId: keyof Appointment;
  status: keyof Appointment;
  style: keyof Appointment;
  subject: keyof Appointment;
  to: keyof Appointment;
}

type SchedulerView = {
  type: string;
  showWeekends: boolean;
  timeRuler: {
    scaleStartHour: number;
    scaleEndHour: number;
  };
};

function App(): JSX.Element {
  const myScheduler = useRef<JqxScheduler>(null);

  const {
    height,
    date,
    source,
    views,
    appointmentDataFields
  } = useMemo<{
    height: number;
    date: ISchedulerProps['date'];
    source: any;
    views: SchedulerView[];
    appointmentDataFields: AppointmentDataFields;
  }>(() => {
    const sourceObj = {
      dataFields: [
        { name: "id", type: "string" },
        { name: "status", type: "string" },
        { name: "about", type: "string" },
        { name: "address", type: "string" },
        { name: "company", type: "string" },
        { name: "name", type: "string" },
        { name: "style", type: "string" },
        { name: "calendar", type: "string" },
        { name: "start", type: "date", format: "yyyy-MM-dd HH:mm" },
        { name: "end", type: "date", format: "yyyy-MM-dd HH:mm" }
      ],
      dataType: "json",
      id: "id",
      url: 'appointments.txt'
    };

    const dataAdapter = new jqx.dataAdapter(sourceObj);

    const appointmentDataFields: AppointmentDataFields = {
      description: "about",
      from: "start",
      id: "id",
      location: "address",
      resourceId: "calendar",
      status: "status",
      style: "style",
      subject: "name",
      to: "end"
    };

    const date = new jqx.date(2028, 11, 17);

    const height = 600;

    const views: SchedulerView[] = [
      { type: "dayView", showWeekends: true, timeRuler: { scaleStartHour: 7, scaleEndHour: 21 } },
      { type: "weekView", showWeekends: true, timeRuler: { scaleStartHour: 7, scaleEndHour: 21 } },
      { type: "timelineDayView", showWeekends: true, timeRuler: { scaleStartHour: 7, scaleEndHour: 21 } },
      { type: "timelineWeekView", showWeekends: true, timeRuler: { scaleStartHour: 7, scaleEndHour: 21 } }
    ];

    return { height, date, source: dataAdapter, views, appointmentDataFields };
  }, []);

  return (
    <JqxScheduler
      theme="tailwind-blue-dark"
      ref={myScheduler}
      width="100%"
      height={height}
      date={date}
      source={source}
      view="weekView"
      views={views}
      appointmentDataFields={appointmentDataFields}
    />
  );
}

export default App;

Learn more

More React Scheduler demos