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

Angular resourceSettings.dataSource two way binding

Hello,
I read this thread http://www.syncfusion.com/forums/119220/angular-use-group , and i have question.
Can we load resourceSettings.dataSource from server(Ajax) and then bind to corresponding resourceSettings.dataSource?

<code>
var resourceData = [
                {
                    field: "roomId",
                    title: "Room",
                    name: "Rooms", allowMultiple: false,
                    resourceSettings: { dataSource: $scope.roomDataSource,
                        text: "text", id: "id", groupId: "groupId",color:"color"
                    }
                },
                {
                    field: "ownerId",
                    title: "Owner",
                    name: "Owners", allowMultiple: true,
                    resourceSettings: { dataSource: $scope.ownerDataSource,
                        text: "text", id: "id", groupId: "groupId", color: "color"
                    }
                }];
</code>

3 Replies

SK Sarath Kumar P K Syncfusion Team July 21, 2015 03:41 PM UTC

Hi Desfero,

 

Thank you for using Syncfusion products.

 

Since the resourceSettings.dataSource value is provided with one-way data binding support, therefore it is not possible to load the resourceSettings dataSource values through ajax post in angular sample. Therefore, we have prepared a schedule angular sample with ajax post to bind the whole resource data through setmodel, which can be downloaded from the following location.

 http://www.syncfusion.com/downloads/support/forum/119670/ze/ScheduleSample-935388532

 

Kindly have a look at the sample and please let us know, if you need any further assistance on this.

 

Regards,
Sarath Kumar P K



DE desfero July 23, 2015 10:14 PM UTC

Thank you for your response. But i have another question. Can i change after some user interaction order from ["Rooms", "Owners"] to  ["Owners", "Rooms"]?
I try to do this like in you example, firsty a get formatted resources in order ["Rooms", "Owners"] 
             $.ajax({
                 url: "/orderby/rooms",
                 success: function (data) {
                     $("#Schedule1").ejSchedule("option", "group", { resources: ["Rooms", "Owners"] });
                     $("#Schedule1").ejSchedule("option", "resources", data);                     
                 }
             });

and after some user interaction i get new formatted resource in reversed order
             $.ajax({
                 url: "/orderby/owners",
                 success: function (data) {
                     $("#Schedule1").ejSchedule("option", "group", { resources: ["Owners", "Rooms"] });
                     $("#Schedule1").ejSchedule("option", "resources", data);                     
                 }
             });

but this solution doesn't work correctly.


SK Sarath Kumar P K Syncfusion Team July 27, 2015 12:51 PM UTC

Hi Desfero,  

Thanks for your update. 

We have analyzed your requirement to interchange the resources order from [“Rooms”, ”Owners”] to [“Owners”, ”Rooms”] and would like to let you know that it can be done by changing the order of resource object details in the resources collection. The values that we usually provide in the group property is only for specifying the levels/groups of the multiple resources to render on the Schedule control. Therefore, if you need to interchange the levels, we request you to change the resources data collection in the post action. 


Please refer the following code snippet to interchange the group and resources.

 

<code>

public JsonResult About()

{

    rooms.Add(new Rooms { text = "ROOM1", id = "1", groupId = "1",color = "#cb6bb2" });

    rooms.Add(new Rooms { text = "ROOM2", id = "2",groupId = "1", color = "#56ca85" });

 

    owner.Add(new Rooms { text = "Nancy", id = "1", groupId = "1", color = "#ffaa00" });

    owner.Add(new Rooms { text = "Steven", id = "3", groupId = "2", color = "#f8a398" });

    owner.Add(new Rooms { text = "Michael", id = "5", groupId = "1", color = "#7499e1" });

 

    resSettings.Add(new ResourceSettings { dataSource = rooms, text = "text", id = "id", groupId = "groupId", color = "color" });

    resSettings.Add(new ResourceSettings { dataSource = owner, text = "text", id = "id", groupId = "groupId", color = "color" });

 

    //Interchange group and resource

 

    resource.Add(new Resource { field = "ownerId", title = "Owner", name = "Owners", allowMultiple = true, resourceSettings = resSettings[1] });

    resource.Add(new Resource { field = "roomId", title = "Room", name = "Rooms", allowMultiple = false, resourceSettings = resSettings[0] });

           

    return Json(resource, JsonRequestBehavior.AllowGet);

}

</code>

 

We have modified the sample based on your requirement to interchange the group and resources, which can be downloaded from the following location  

http://www.syncfusion.com/downloads/support/forum/119670/ze/Schedule-747619550

 

Kindly try the above sample and let us know if you need any further assistance on this. 

Regards,

Sarath Kumar P K


Loader.
Live Chat Icon For mobile
Up arrow icon