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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change resources in code

Thread ID:

Created:

Updated:

Platform:

Replies:

121950 Feb 11,2016 08:03 AM UTC Feb 12,2016 01:08 PM UTC JavaScript 1
loading
Tags: ejSchedule
Jens Bo Frederiksen
Asked On February 11, 2016 08:03 AM UTC

Hi,

I am trying to use ejSchedule to display events for multiple resources. This works fine as long as the resource data is static (in my case loaded via DataManager). 

Now I would like to enable the user to select what resources to display as opposed to displaying all resources. Is there a way to "refresh" the schedule view and take new resource data into account?

Br,
JensBo

Karthigeyan Krishnamurthi [Syncfusion]
Replied On February 12, 2016 01:08 PM UTC

Hi JensBo,

Thanks for contacting Syncfusion support.

We have prepared a sample for your requirement “Need to dynamically display the resources based on user selection“ and that can be downloaded from the following location,
http://www.syncfusion.com/downloads/support/forum/121950/ze/ScheduleCRUDJS943958963

In the above sample we have initially displayed all the resources and their corresponding datum. If the user uncheck/check the particular resource, the respective resource will be removed/added in the schedule control. Kindly refer to the following code example that we have used in the above sample.
<Code>

function onChange(args) { // this function will be called when the resource is checked/unchecked

        var schObj = $("#Schedule1").data("ejSchedule");

        dataManager2 = ej.DataManager({

            url: '@Url.Action("owner","Home")',

            crossDomain: true

        });       

        dataManager2.adaptor = new ej.UrlAdaptor();

        var ds = dataManager2.executeQuery(new ej.Query());

        ds.done(function (e) {                  

            var resourceObject = ej.DataManager(e.result).executeLocal(ej.Query().where("resText", ej.FilterOperators.equal, args.model.text)); // here we will filter particular resource that is checked/unchecked

            if (args.isChecked)

                changeClick(resourceObject);

            else

                removeClick(resourceObject);

        });

       

    }

function changeClick(args) { // this function will be called when the resourse is checked

        var schObj = $("#Schedule1").data("ejSchedule");

        schObj.model.resources[0].resourceSettings.dataSource.push(args[0]); // here we are dynamically adding the checked resource

        var resVal = schObj.model.resources[0].resourceSettings.dataSource;

        var dataManager1 = ej.DataManager({

            url: '@Url.Action("GetData","Home")',

            //  url:"/Home/GetData",

            crudUrl: '@Url.Action("Batch", "Home")',

            crossDomain: true

        });


         ------------

         ------------

    }

     function removeClick(value) { // this function will be called when the resourse is un-checked

                var schObj = $("#Schedule1").data("ejSchedule");

                ej.DataManager(schObj.model.resources[0].resourceSettings.dataSource).remove("resId", value[0].resId); // here we are dynamically removing the unchecked resource

                var resVal = schObj.model.resources[0].resourceSettings.dataSource;

                $("#Schedule1").ejSchedule({

                    resources: [{

                        field: "OwnerId",

                        title: "Owner",

                        name: "Owners", allowMultiple: true,

                        resourceSettings: {

                            dataSource: resVal,

                            text: "resText", id: "resId", color: "rescolor"

                        }

                    }],

                });

            }
</Code>

Regards,
Karthigeyan


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;