Refresh only the Resources

Hello,
there is a way in scheduler to refresh only the resources?

I have following problem:

- in eventRender, dependently from a state of the appointments I want to set the Name of resource where this appointment is scheduled.

I do it using following code snippet:

    function ManageRoomVisibility(locklevel, or_ID_involved) {
        debugger;
        var scheduleObj = document.querySelector('.e-schedule').ej2_instances[0];
        var involvedRoom = scheduleObj.resources[1].dataSource.find(function (p) { return p.or_ID == or_ID_involved });
        if (locklevel < 3) {
            involvedRoom.roomName = '****';
        }
        else {
            involvedRoom.roomName = involvedRoom.or_ShortName;
        }
    }

but now I have to refresh the scheduler to show the name changed.
ManageRoomVisibility was called in Eventrendered, so if I refresh all scehdule eventRendered event is fired again, and there is an infinite loop.


 

1 Reply 1 reply marked as answer

RV Ravikumar Venkatesan Syncfusion Team October 19, 2020 12:37 PM UTC

Hi Gabriele, 

Greetings from Syncfusion support. 

We have validated your requirement at our end. Currently, we don’t have support for refreshing the resources alone. So, we have prevented the infinite loop of Schedule refresh by using a flag within dataBound event which can be referred from the following link, 

[Index.cshtml] 
<script type="text/javascript"> 
 
    var isChanged = false; 
 
    function onEventRendered(args) {    
        // Preventing the infinite looping by checking isChanged is set to false or not      
        if (!isChanged) { 
            ManageRoomVisibility(args.data.RoomId); 
        } 
    } 
 
    function onDataBound(args) { 
        if (!isChanged) { 
            var scheduleObj = document.querySelector('.e-schedule').ej2_instances[0]; 
            scheduleObj.refresh(); 
            // Preventing the infite looping by setting up isChanged variable to true 
            isChanged = true; 
        } 
    } 
 
    function ManageRoomVisibility(or_ID_involved) { 
        var scheduleObj = document.querySelector('.e-schedule').ej2_instances[0]; 
        var involvedRoom = scheduleObj.resources[0].dataSource.filter(function (p) { return p.id === or_ID_involved }); 
        if (involvedRoom.length > 0) { 
            involvedRoom[0].name = 'Changed name'; 
        } 
    } 
</script> 

Kindly try the above sample and get back to us if you need any further assistance. 

Regards, 
Ravikumar Venkatesan 


Marked as answer
Loader.
Up arrow icon