I'm attempting to create resources via client-side code. I've tried several approaches and I'm not certain why they haven't worked.
First. I tried creating a web method that returned a Telerik.Web.UI.Resource object:
and then using this method per the documentation:
However, the alert is never executed and the resource doesn't appear.
I've also tried creating an entire collection of resources and passing them back:
And here is the JavaScript code to display the resource:
But this isn't working either.
So, I'm looking for two things. FIrst, an explanation on how to add a resource via client-side code. And secondly, where can I find some good documentation for the client-side methods. The help file that get's shipped with the controls is rather...thin,
Thanks much!
First. I tried creating a web method that returned a Telerik.Web.UI.Resource object:
| [WebMethod] |
| public static Telerik.Web.UI.Resource GetResource() |
| { |
| Telerik.Web.UI.Resource r1 = new Telerik.Web.UI.Resource("Employee", "100", "Frank Sminth"); |
| return r1; |
| } |
and then using this method per the documentation:
| $("#AddResource").click(function() { |
| var scheduler = $find("<%=RadScheduler1.ClientID %>"); |
| if (scheduler == null) alert("No Control"); |
| $.ajax({ |
| type: "POST", |
| url: "Default.aspx/GetResource", |
| data: "{}", |
| contentType: "application/json; charset=utf8", |
| dataType: "json", |
| success: function(r1) { |
| scheduler.SchedulerResourceCollection.add(r1); |
| scheduler.Rebind(); |
| alert("OK"); |
| } |
| }); |
| }); |
However, the alert is never executed and the resource doesn't appear.
I've also tried creating an entire collection of resources and passing them back:
| [WebMethod] |
| public static Telerik.Web.UI.ResourceCollection GetResource() |
| { |
| Telerik.Web.UI.ResourceCollection rc = new Telerik.Web.UI.ResourceCollection(); |
| Telerik.Web.UI.Resource r1 = new Telerik.Web.UI.Resource("Employee", "100", "Frank Sminth"); |
| rc.Add(r1); |
| return rc; |
| } |
And here is the JavaScript code to display the resource:
| $("#AddResource").click(function() { |
| var resource = new Telerik.Web.UI.SchedulerResource(); |
| var scheduler = $find("<%=RadScheduler1.ClientID %>"); |
| if (scheduler == null) alert("No Control"); |
| $.ajax({ |
| type: "POST", |
| url: "Default.aspx/GetResource", |
| data: "{}", |
| contentType: "application/json; charset=utf8", |
| dataType: "json", |
| success: function(rc) { |
| scheduler.set_resources(rc); |
| alert("OK"); |
| } |
| }); |
| }); |
But this isn't working either.
So, I'm looking for two things. FIrst, an explanation on how to add a resource via client-side code. And secondly, where can I find some good documentation for the client-side methods. The help file that get's shipped with the controls is rather...thin,
Thanks much!