Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #113372
    michaelsanders
    Participant

    What’s the recommended way to update Smart Scheduler data dynamically in web app?

    #113374
    admin
    Keymaster

    Hi,

    All you need to do is to dynamically set the dataSource property to a new value.

    Example:

    const scheduler = document.querySelector('smart-scheduler');
    
    // SET / REPLACE DATA (preferred for async updates)
    scheduler.dataSource = [
      { id: 1, label: 'Event A', dateStart: new Date(), dateEnd: new Date() }
    ];
    
    // UPDATE EXISTING EVENT (requires refresh)
    const e = scheduler.dataSource.find(x => x.id === 1);
    e.dateEnd = new Date(Date.now() + 3600_000);
    scheduler.refresh();
    
    // ADD EVENT
    scheduler.dataSource = [
      ...scheduler.dataSource,
      { id: 2, label: 'Event B', dateStart: new Date(), dateEnd: new Date() }
    ];
    
    // REMOVE EVENT
    scheduler.dataSource = scheduler.dataSource.filter(x => x.id !== 1);

    Best regards,
    Markov

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

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