This is a migrated thread and some comments may be shown as answers.

Error with binding remoted resources

4 Answers 224 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Claude asked on 09 Sep 2013, 03:45 PM
Hello,

I have some troubles about resources in scheduler, so I come here to find some help.
I want to make a scheduler for some employees. For a better readability, I would like that every user's event has a unique color. Colors are stored in database, on with all User's data. So I decided to use Resources to do this.

However, when I define a remote loading for resources, then scheduler raise on error (see below) and stop working.
Here is Razor code :

@(Html.Kendo().Scheduler<EventViewModel>()
          .Name("calendar")
          .Date(DateTime.Now)
          .Timezone("Etc/UTC")
          .Views(v =>
          {
              v.DayView();
              v.WeekView(conf => conf.Selected(true));
              v.MonthView();
              v.AgendaView();
          })
          .DataSource(source => source
              .Model(conf =>conf.Id(f => f.EventId))
              .AutoSync(true)
              .Read("GetAllEvents", "Activity")
              .Create("CreateEvent", "Activity")
              .Destroy("DestroyEvent", "Activity")
              .Update("UpdateEvent", "Activity")
          )
        .Resources(resources => resources.Add(m => m.Creator)
            .Title("User")
            .DataTextField("Name")
            .DataValueField("UserId")
            .DataColorField("Color")
            .DataSource(source => source
                .Read(read => read.Action("GetUsersList", "Activity"))))
)

If I remove .Resources() part, all is working great. Defining some static resources (with .BindTo(new[]{...})) works well too, but this way is not handy.
Finally, when I want to define a resources section with remote loading, I got the following error messages in FireFox :

TypeError: t is undefined @ /Scripts/kendo/2013.2.716/kendo.all.min.js:31
TypeError: n.slice is not a function @ /Scripts/kendo/2013.2.716/kendo.all.min.js:11


Users list is perfeclty loaded in my page. Here is GetUsersList() code :
public ActionResult GetUsersList([DataSourceRequest] DataSourceRequest request)
{
    var items = from x in db.Users
                        select new {x.UserId, Name = x.FirstName + " " + x.LastName, x.Color};
    return Json(items.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

One thing I notice is that, when resources are loaded up, scheduler does not trigger any loading for events. I'm not yet used to scheduler helper, so it's not really easy to understand what issue is.

Thanks you for your help.

Best Regards,
Claude

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 10 Sep 2013, 06:57 AM
Hello Claude,

I suspect that the issue is caused by the use of DataSourceResult in the action method serving the resources data. As you may know this is not required and should be omitted:

public ActionResult GetUsersList()
{
    var items = from x in db.Users
                        select new {x.UserId, Name = x.FirstName + " " + x.LastName, x.Color};
 
    return Json(items, JsonRequestBehavior.AllowGet);
}

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Claude
Top achievements
Rank 1
answered on 10 Sep 2013, 11:34 AM
Hello Rosen and thanks you for your answer.

So, I tried your solution and removed DataRequest stuff. I did not modify anything else.
Now, scheduler does not crash anymore, but resources still not working. I can see that resources and events are well loaded, but binding fail with the following error :

TypeError: t is undefined @ /Scripts/kendo/2013.2.716/kendo.all.min.js:31

Is there some options I forgot  ?

Regards,
Claude
0
Rosen
Telerik team
answered on 11 Sep 2013, 06:07 AM
Hi Claude,

Unfortunately, I'm not sure what may be the cause for the described error looking at the details provided. Thus, please send us a small runnable sample in which it can be observed locally.

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Claude
Top achievements
Rank 1
answered on 17 Sep 2013, 01:00 PM
Hi Rosen,

I finally found the bug. The issue come from model declaration in Resources part :
.Resources(resources => resources.Add(m => m.Creator.UserId)
Error comes from "Creator.UserId" which Sheculer does not like. So I modified my view model to integrate this information to avois this situation :
.Resources(resources => resources.Add(m => m.CreatorId)
Now it works. Please ote that "t is undefined" error still raising,

Thanks you for your help.

Regards,
Claude
Tags
Scheduler
Asked by
Claude
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Claude
Top achievements
Rank 1
Share this question
or