Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #109500
    Ondřej
    Participant

    Hello,

    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>

    #109572
    admin
    Keymaster

    Hi,

    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,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

    #109605
    Ondřej
    Participant

    Thank you, is then possible to trigger loading indicator explicitly?

    Thank you

    #109606
    Ondřej
    Participant

    And 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>

    #109607
    admin
    Keymaster

    Hi,

    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.asp

    Regards,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.