jQuery UI Widgets › Forums › Scheduler › I’m analyzing: Scheduler and could use expert input.
Tagged: scheduler
This topic contains 1 reply, has 2 voices, and was last updated by admin 7 months, 3 weeks ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
How do I bind an array of events from React state to jqxScheduler?
Hi,
import React, { useState } from 'react'; import JqxScheduler from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxscheduler'; const SchedulerComponent = () => { const [events, setEvents] = useState([ { id: 1, description: 'Meeting', location: 'Room 1', start: new Date(2026, 2, 19, 9, 0), end: new Date(2026, 2, 19, 10, 0), }, { id: 2, description: 'Lunch', location: 'Cafeteria', start: new Date(2026, 2, 19, 12, 0), end: new Date(2026, 2, 19, 13, 0), }, ]); // Scheduler source const source = { dataType: 'array', dataFields: [ { name: 'id', type: 'number' }, { name: 'description', type: 'string' }, { name: 'location', type: 'string' }, { name: 'start', type: 'date' }, { name: 'end', type: 'date' }, ], id: 'id', localData: events, }; const dataAdapter = new window.jqx.dataAdapter(source); const appointmentDataFields = { id: 'id', description: 'description', location: 'location', start: 'start', end: 'end', }; return ( <div> <JqxScheduler width={800} height={600} source={dataAdapter} appointmentDataFields={appointmentDataFields} view="weekView" date={new Date(2026, 2, 19)} /> </div> ); }; export default SchedulerComponent;Update Scheduler When State Changes
If you want to dynamically add events:
const addEvent = () => { const newEvent = { id: events.length + 1, description: 'New Event', location: 'Room 2', start: new Date(2026, 2, 20, 14, 0), end: new Date(2026, 2, 20, 15, 0), }; setEvents([...events, newEvent]); };Update Scheduler When State Changes
If you want to dynamically add events:
const addEvent = () => {
const newEvent = {
id: events.length + 1,
description: ‘New Event’,
location: ‘Room 2’,
start: new Date(2026, 2, 20, 14, 0),
end: new Date(2026, 2, 20, 15, 0),
};setEvents([…events, newEvent]);
}; -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.