JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Scheduler › DataAdapter – virutalDataSource
- This topic has 4 replies, 2 voices, and was last updated 8 months ago by
admin.
-
AuthorPosts
-
December 29, 2023 at 11:55 am #109500
Ondřej
ParticipantHello,
I need to add parameters to Scheduler dataSource API call, so I am trying to use virtualDataSource function, but function is not triggered.
<div>const dataSource = new window.Smart.DataAdapter({ virtualDataSource: function( resultCallbackFunction: any, details: any ) { console.log('virtualDataSource', details) let startDate = new Date(); let endDate = new Date(); if (scheduler !== null) { const viewDates = scheduler.getViewDates() startDate = viewDates[0]; endDate = viewDates[1]; } const params = { start: startDate, end: endDate } axios.get('/api/v1/get-records', { params: params }) .then(res => { resultCallbackFunction({ dataSource: res.data.records }) }) .catch(err => { console.log(err); }); }, dataFields: [{ name: 'id', type: 'string' }, { name: 'label', type: 'string' }, { name: 'dateStart', type: 'date' }, { name: 'dateEnd', type: 'date' }, { name: 'class', type: 'string' } ] });
Thanks for help
</div>
December 29, 2023 at 1:48 pm #109572admin
KeymasterHi,
This function is not available for usage in Scheduler. You can bind it to an Array, JSON, CSV, TSV or XML. For binding to remote data, you can look at https://www.htmlelements.com/demos/scheduler/server-side-mysql-php/
Regards,
MarkovSmart UI Team
https://www.htmlelements.com/December 29, 2023 at 2:31 pm #109605Ondřej
ParticipantThank you, is then possible to trigger loading indicator explicitly?
Thank you
December 29, 2023 at 4:49 pm #109606Ondřej
ParticipantAnd I have another question when i add event listener in React like this on Scheduler component
<div>onDateChange={onSchedulerDateChange}
<div>
<div>const onSchedulerDateChange = (event) => { // view console.log(schedulerRef.current.getViewDates()); };
Then viewDates are still old ones, not for date in event
</div>
</div>
</div>December 30, 2023 at 11:14 pm #109607admin
KeymasterHi,
getViewDates() returns the view start and end dates. When the current date is within the same view, the view start and end dates are the same and does not change.
As for the loading, no, it does not have a property to display a loading indicator. You can use an overlay DIV tag with loading gif and show/hide it dynamically as a solution. For example: https://www.w3schools.com/howto/howto_css_loader.aspRegards,
MarkovSmart UI Team
https://www.htmlelements.com/ -
AuthorPosts
- You must be logged in to reply to this topic.