External Date Navigation

This example demonstrates how can the Timeline navigated externally. Here we have a two-pane layout with a Datepicker on the left and a Timeline on the right. Changing date on the Datepicker will trigger the date change on the Timeline.

The Datepicker updates the selectedDate option of the Timeline in its onChange event, while the Timeline updates the datepicker value from its onSelectedDateChange event.

Get started with this example

Demo

Loading the live demo

Preview in full screen

Use a two-panel Timeline navigated by an external date picker — selecting a date syncs the timeline and the picker instantly.

Code

import { Datepicker, Eventcalendar, getJson, setOptions } from '@mobiscroll/react';
import { useCallback, useEffect, useMemo, useState } from 'react';

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

function App() {
  const [myEvents, setEvents] = useState([]);
  const [mySelectedDate, setSelectedDate] = useState(new Date());
  const dayView = useMemo(() => ({ timeline: { type: 'day' } }), []);
  const myResources = useMemo(
    () => [
      { id: 1, name: 'Resource 1', color: 'red' },
      { id: 2, name: 'Resource 2', color: 'orange' },
      { id: 3, name: 'Resource 3', color: 'blue' },
    ],
    [],
  );

  const handleDateChange = useCallback((args) => {
    setSelectedDate(args.value);
  }, []);

  const handleSelectedDateChange = useCallback((args) => {
    setSelectedDate(args.date);
  }, []);

  useEffect(() => {
    getJson(
      'https://trial.mobiscroll.com/filter-resource-events/',
      (events) => {
        setEvents(events);
      },
      'jsonp',
    );
  }, []);

  return (
    <div className="mds-external-nav-timeline mbsc-flex">
      <div className="mds-external-nav-dp">
        <Datepicker value={mySelectedDate} display="inline" onChange={handleDateChange} />
      </div>
      <div className="mds-external-nav-ec mbsc-flex-1-1">
        <Eventcalendar
          data={myEvents}
          selectedDate={mySelectedDate}
          view={dayView}
          resources={myResources}
          onSelectedDateChange={handleSelectedDateChange}
        />
      </div>
    </div>
  );
}

export default App;

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.