Our pure JavaScript Scheduler component


Post by charlene »

Hi

I have defined BryntumSchedulerPro with onEventDrop as below. how do i update eventStore & assignmentStore onEventDrop? Thanks

<BryntumSchedulerPro
                                {...schedulerConfig}
                                startDate={startDate}
                                endDate={endDate}
                                resources={resources}
                                eventStore={eventStore}
                                assignments={assignments}
                                onEventDrop={(data) => handleEventDrop()}
                                ref={orgScheduleRef}
                            />

Post by ghulam.ghous »

Hi Charlene,

If I understood correctly, you want to access the eventStore and assignmentStore and manipulate some records, you can access it using source param in the event onEventDrop. It will be something like this:

onEventDrop:({source})=>{
     console.log(source.eventStore);
     console.log(source.assignmentStore);
}

See the source in the event paramas here https://bryntum.com/products/schedulerpro/docs/api/Scheduler/feature/EventDrag#eventhandler-onEventDrop.

Regards,
Ghous


Post by charlene »

Hi Ghous,

Upon eventDrop, how do i update the eventStore and assignmentStore after accessing these parameters from source? Thanks


Post by ghulam.ghous »

Hi Charlene,

I need to you define your use case here, like what you are trying to achieve. Then we will be in a better position to suggest you the best solution.

Here's a scenario: If you want to update a specific record, you can update do something like this:

source.eventStore.getById(recordIdYouWantToUpdate).set('name', 'hello')
source.assignmentStore.getById(AssignmentRecordIdYouWantToUpdate).set(//your field and value)

https://bryntum.com/products/schedulerpro/docs/api/SchedulerPro/model/EventModel#function-set
https://bryntum.com/products/schedulerpro/docs/api/SchedulerPro/model/AssignmentModel#function-set

Regards,
Ghous


Post by charlene »

Hi Ghous,

yes that is what im trying to achieve. Upon updating the eventStore, how do I get the latest events data? I tried to get the eventStore.data (eventStore passed as props to BryntumSchedulerPro), but the data resource is not updated. I do not want to fetch the ModelClass from the eventStore.

const [eventStore, setEventStore] = useState({
        data: null
    });
//on initial fetch of data from API
setEventStore(prev => ({ ...prev, data: response.data.events }));

//Bryntum config
<BryntumSchedulerPro
                                {...schedulerConfig}
                                startDate={startDate}
                                endDate={endDate}
                                resources={resources}
                                eventStore={eventStore}
                                assignments={assignments}
                                onEventDrop={(data) => handleEventDrop(data, orgScheduleRef)}
                                key={`${resources} ${subTypes}`}
                                ref={orgScheduleRef}
                            />

Post by ghulam.ghous »

Hi Charlene,

Can you please elaborate a bit what you are trying to achieve? By "I do not want to fetch the ModelClass from the eventStore" you mean, you do not want to use source.eventStore.getById(recordIdYouWantToUpdate) this to get the event?

Regards,
Ghous


Post by charlene »

Hi Ghous,

I will like to get the list of json object of all the events - like what I can retrieve from (BryntumSchedulerPro props) eventStore.data / source.eventStore._data. But i noticed these does not return me the latest data. source.eventStore.data is returning me as undefined. Please advise how to retrieve the json object of all the events, I do not want to retrieve the ModelClass of the events.

Thanks


Post by ghulam.ghous »

Hi Charlene,

You can get all the records by using records or allRecords. The only difference is allRecords returns all the records irrespective of the filters etc, while records returns only the visible records.
https://bryntum.com/products/schedulerpro/docs/api/Scheduler/data/EventStore#property-records
https://bryntum.com/products/schedulerpro/docs/api/Scheduler/data/EventStore#property-allRecords

source.eventStore.records //visible records
source.eventStore.allRecords // all records

This will return all the data. You can access the json data by using record.data. But all the records will be model classes. Please note that there is no way that you can get all the json.

Regards,
Ghous


Post by charlene »

That works, thanks Ghous


Post by ghulam.ghous »

Glad it worked. If you have need any further assistance, please don't hesitate to reach out to us.


Post Reply