We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How can I insert new resource in a Schedule control from the client side?

Hi,

I have a Schedule control grouped horizontally like in this demo: http://mvc.syncfusion.com/demos/web/schedule/horizontalresourcegrouping.

I want to insert from the client side a new resource, for example to add "John" to "ROOM2".

Thanks,
Cornel.

3 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team February 17, 2017 11:43 AM UTC

Hi Cornel, 
 
Thank you for contacting Syncfusion support. 
 
We have prepared the sample to dynamically add the resource which can be download from the below location. 
 
In the above sample, when a button is clicked, new resource will be added to the Scheduler. Kindly refer the below code example used in the sample. 
 
<Code> 
$("#BindData").click(function () { 
        var resData = [{ text: "Oliver", id: "4", groupId: "2", color: "#ffaa00" }]; 
        var schObj = $("#Schedule1").data("ejSchedule"); 
        schObj.model.resources[1].resourceSettings.dataSource.push(resData[0]); // here we are dynamically adding the resource 
        var resVal = schObj.model.resources[1].resourceSettings.dataSource; // here total no of resources will be stored 
        var modelRoomData =  @Html.Raw(Json.Encode(ViewBag.Rooms)); // here we are getting the Room data collection from controller 
        var modelAppData =  @Html.Raw(Json.Encode(ViewBag.datasource));  
        var AppData = []; 
        for (var i = 0; i < modelAppData.length; i++) { 
            AppData[i] = { 
                Id: modelAppData[i].Id, 
                Subject: modelAppData[i].Subject, 
                StartTime: new Date(modelAppData[i].StartTime.match(/\d+/)[0] * 1), 
                EndTime: new Date(modelAppData[i].EndTime.match(/\d+/)[0] * 1), 
                AllDay: modelAppData[i].AllDay, 
                Recurrence: modelAppData[i].Recurrence, 
                RecurrenceRule: modelAppData[i].RecurrenceRule, 
                OwnerId:modelAppData[i].OwnerId, 
                RoomId:modelAppData[i].RoomId 
            } 
        } 
        ------------ 
        ------------ 
    }); 
</Code> 
 



CA Cornel Amarandei February 17, 2017 12:01 PM UTC

Hi Karthigeyan,

Thanks for your information. It works very well.

Regards,
Cornel.


MP Mahesh Palanisamy Syncfusion Team February 20, 2017 12:28 PM UTC

Hi Cornel, 
 
We are glad to hear that our provided solution worked well at your end. 

Kindly let us know, if you need any further assistance on this. 

Regards, 
Mahesh 


Loader.
Live Chat Icon For mobile
Up arrow icon