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

Error canceling event editor template with resource dropdownlist

4 Answers 55 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
salvador
Top achievements
Rank 1
salvador asked on 08 Nov 2013, 11:51 AM
Hi everyone,

    I have created an event editor template and I have added a resource dropdownlist as in this thread.

    http://www.kendoui.com/forums/kendo-ui-web/scheduler/how-to-create-editable-template-with-the-resource-.aspx

    But I think that occurs a bug when you open the event a second time and you close it with cancel button.

    For example:
    1) You open the event window and you change the resourse. If you click Save button all is OK, the event move to selected resource.
    2) You open the same event. In resource dropdownlist the selected option is the updated resource.
    3) But if you click  Cancel button then the event is moved to old resource in all views (day, week, month and agenda). The strangest thing is that in database doesn't occurs any update, it is the new value but in scheduler it is showed the old value.

    If you open another event all work correctly, the problem is only when you open a second time the same event and you click cancel.

Thank you
Regards

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 12 Nov 2013, 11:47 AM
Hi Salvador,

 
Basically such behavior can be observed when either the server doesn't return the updated record back to the client side or it returns it in invalid format and the pristine collection of the dataSource is not updated. From the provided information however it's not clear for us what is your current setup - could you please provide runable example where the issue is reproduced (or the client and server side code)? This would help us pinpoint the exact reason for this behavior.

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
salvador
Top achievements
Rank 1
answered on 12 Nov 2013, 03:06 PM
Hi Vladimir,

    My update service returns a null value, but I thought that all works fine. The value was updated in database and in scheduler.

    But as you said something is wrong.

    It's dificult to give you a runable example, I copy a summary of the server side code.
public class DataSourceResult
{
    public System.Collections.IEnumerable Data { get; set; }
}
 
public static DataSourceResult ToDataSourceResult(List<CallEvent> queryable)
{
    return new DataSourceResult
    {
        Data = queryable.ToList(),
    };
}
 
[WebMethod(EnableSession = true)]
public DataSourceResult SchedulerRead()
{
    CoreDataContext ctx = new CoreDataContext();
 
    return ToDataSourceResult(ctx.Scheduler_GetCalls()
            .Select(c => new CallEvent()
            {
                serviceCode = c.serviceCode,
                title = string.Concat(c.serviceCode, " - ", c.description),
                start = c.startDate,
                end = c.endDate,
                technicianCode = c.technicianCode,                   
            })
            .ToList());
}
 
[WebMethod(EnableSession = true)]
public DataSourceResult SchedulerUpdate(List<CallEvent> callEvents)
{
    CoreDataContext ctx = new CoreDataContext();
 
    foreach (var c in callEvents)
    {
        ctx.Scheduler_UpdateCall(c.serviceCode, c.start, c.end, c.technicianCode);
    }
 
    return new DataSourceResult
    {
        Data = null
    };
}
Thank you for your help
Regards
0
Vladimir Iliev
Telerik team
answered on 13 Nov 2013, 07:19 AM
Hi Salvador,

 
Basically the Grid expects from the server to either return a 'null' or populated DataSourceResult as response - in current case where you return DataSourceResult object with Data property set to null the pristine collection is not updated which leads to current behavior. Please check the examples below:

[WebMethod(EnableSession = true)]
public DataSourceResult SchedulerUpdate(List<CallEvent> callEvents)
{
    CoreDataContext ctx = new CoreDataContext();
 
    foreach (var c in callEvents)
    {
        ctx.Scheduler_UpdateCall(c.serviceCode, c.start, c.end, c.technicianCode);
    }
 
    return new DataSourceResult() {
        Data = callEvents
    };
}

[WebMethod(EnableSession = true)]
public DataSourceResult SchedulerUpdate(List<CallEvent> callEvents)
{
    CoreDataContext ctx = new CoreDataContext();
 
    foreach (var c in callEvents)
    {
        ctx.Scheduler_UpdateCall(c.serviceCode, c.start, c.end, c.technicianCode);
    }
 
    return null;
}
Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
salvador
Top achievements
Rank 1
answered on 13 Nov 2013, 08:24 AM
Thank you very much Vladimir, the problem have been solved.

I was checking several example code and I thought that update method was correct.
Tags
Scheduler
Asked by
salvador
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
salvador
Top achievements
Rank 1
Share this question
or