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

Grid DataSource.Update not firing

3 Answers 1253 Views
Grid
This is a migrated thread and some comments may be shown as answers.
App
Top achievements
Rank 1
App asked on 23 Nov 2015, 05:18 PM

I cant seem to find where I am going wrong with this, i'm not seeing any javascript errors.

My update action is not being called. I notice that the Update button of the grid row takes 4-5 seconds to return to an edit. This grid is loaded via jquery load into a div. 

 

Here is the grids cshtml:

@model PathologyScheduling.Models.TaskScheduleViewModel
@using PathologyScheduling.Models;
@( Html.Kendo().Grid<PathologyScheduling.Models.TaskScheduleViewModelRecord>(Model.Records)
        .Name("TaskScheduleGrid")
    .Editable(editable =>
    {
        editable.Mode(GridEditMode.InLine);
    })
    .ToolBar(tools => tools.Pdf())
    //.Scrollable()//scrolling => scrolling.Enabled(true).Virtual(false)) 
    .Resizable(r => r.Columns(true))
    .ColumnResizeHandleWidth(10)
    .HtmlAttributes(new { style = " width: 100%" })
    .Pdf(pdf => pdf
        .AllPages().Landscape()
            .FileName("TaskSchedule_" + @Model.SelectedScheduleId + ".pdf")
        .ProxyURL(Url.Action("Pdf_Export_Save", "Home")))
    .Columns(x =>
    {
        x.Command(item => item.Edit());
        x.Bound(item => item.Date).Format(@"{0:ddd (dd)}")
            .Title("Date").Locked(true);
        x.Bound(item => item.Value)
            .Title("FTE");
        x.Bound(item => item.SingleDay)
            .ClientTemplate("#= renderMultiSelect(data.SingleDay) #")
            .EditorTemplateName("StaffListSingleDay")
            .Title(TaskScheduleViewModelRecord.Constants.SingleDay);
        x.Bound(item => item.HalfDay)
            .ClientTemplate("#= renderMultiSelect(data.HalfDay) #")
            .EditorTemplateName("StaffListHalfDay")
            .Title(TaskScheduleViewModelRecord.Constants.HalfDay);
        x.Bound(item => item.Gross)
             .ClientTemplate("#= renderMultiSelect(data.Gross) #")
            .EditorTemplateName("StaffListGross")
             .Title(TaskScheduleViewModelRecord.Constants.Gross);
        x.Bound(item => item.LightMicroscopy)
             .ClientTemplate("#= renderMultiSelect(data.LightMicroscopy) #")
            .EditorTemplateName("StaffListLightMicroscopy")
            .Title(TaskScheduleViewModelRecord.Constants.LightMicroscopy);
        x.Bound(item => item.Pool2X)
              .ClientTemplate("#= renderMultiSelect(data.Pool2X) #")
            .EditorTemplateName("StaffListPool2X")
            .Title(TaskScheduleViewModelRecord.Constants.Pool2X);
        x.Bound(item => item.Pool15X)
              .ClientTemplate("#= renderMultiSelect(data.Pool15X) #")
            .EditorTemplateName("StaffListPool15X")
            .Title(TaskScheduleViewModelRecord.Constants.Pool15X);
        x.Bound(item => item.Pool1X)
              .ClientTemplate("#= renderMultiSelect(data.Pool1X) #")
            .EditorTemplateName("StaffListPool1X")
            .Title(TaskScheduleViewModelRecord.Constants.Pool1X);
        x.Bound(item => item.Pool075X)
              .ClientTemplate("#= renderMultiSelect(data.Pool075X) #")
            .EditorTemplateName("StaffListPool075X")
            .Title(TaskScheduleViewModelRecord.Constants.Pool075X);
        x.Bound(item => item.Pool05X)
              .ClientTemplate("#= renderMultiSelect(data.Pool05X) #")
            .EditorTemplateName("StaffListPool05X")
            .Title(TaskScheduleViewModelRecord.Constants.Pool05X);
        x.Bound(item => item.Pool025X)
              .ClientTemplate("#= renderMultiSelect(data.Pool025X) #")
            .EditorTemplateName("StaffListPool025X")
            .Title(TaskScheduleViewModelRecord.Constants.Pool025X);
        x.Bound(item => item.Gyne1X)
              .ClientTemplate("#= renderMultiSelect(data.Gyne1X) #")
            .EditorTemplateName("StaffListGyne1X")
            .Title(TaskScheduleViewModelRecord.Constants.Gyne1X);
        x.Bound(item => item.Gyne05X)
              .ClientTemplate("#= renderMultiSelect(data.Gyne05X) #")
            .EditorTemplateName("StaffListGyne05X")
            .Title(TaskScheduleViewModelRecord.Constants.Gyne05X);
        x.Bound(item => item.Gyne025X)
              .ClientTemplate("#= renderMultiSelect(data.Gyne025X) #")
            .EditorTemplateName("StaffListGyne025X")
            .Title(TaskScheduleViewModelRecord.Constants.Gyne025X);
        x.Bound(item => item.NonG)
              .ClientTemplate("#= renderMultiSelect(data.NonG) #")
            .EditorTemplateName("StaffListNonG")
            .Title(TaskScheduleViewModelRecord.Constants.NonG);
        x.Bound(item => item.HEM)
             .ClientTemplate("#= renderMultiSelect(data.HEM) #")
            .EditorTemplateName("StaffListHEM")
             .Title(TaskScheduleViewModelRecord.Constants.HEM);
        x.Bound(item => item.Sturgeon)
             .ClientTemplate("#= renderMultiSelect(data.Sturgeon) #")
            .EditorTemplateName("StaffListSturgeon")
             .Title(TaskScheduleViewModelRecord.Constants.Sturgeon);
        x.Bound(item => item.Biochemistry)
             .ClientTemplate("#= renderMultiSelect(data.Biochemistry) #")
            .EditorTemplateName("StaffListBiochemistry")
             .Title(TaskScheduleViewModelRecord.Constants.Biochemistry);
        x.Bound(item => item.Dermpath)
             .ClientTemplate("#= renderMultiSelect(data.Dermpath) #")
            .EditorTemplateName("StaffListDermpath")
            .Title(TaskScheduleViewModelRecord.Constants.Dermpath);
        x.Bound(item => item.Colpos)
             .ClientTemplate("#= renderMultiSelect(data.Colpos) #")
            .EditorTemplateName("StaffListColpos")
            .Title(TaskScheduleViewModelRecord.Constants.Colpos);
        x.Bound(item => item.Liver)
             .ClientTemplate("#= renderMultiSelect(data.Liver) #")
            .EditorTemplateName("StaffListLiver")
            .Title(TaskScheduleViewModelRecord.Constants.Liver);
        x.Bound(item => item.QACytology)
             .ClientTemplate("#= renderMultiSelect(data.QACytology) #")
            .EditorTemplateName("StaffListQACytology")
            .Title(TaskScheduleViewModelRecord.Constants.QACytology);
        x.Bound(item => item.QAHistology)
             .ClientTemplate("#= renderMultiSelect(data.QAHistology) #")
            .EditorTemplateName("StaffListQAHistology")
            .Title(TaskScheduleViewModelRecord.Constants.QAHistology);
        x.Bound(item => item.ResidencyTraining)
             .ClientTemplate("#= renderMultiSelect(data.ResidencyTraining) #")
            .EditorTemplateName("StaffListResidencyTraining")
            .Title(TaskScheduleViewModelRecord.Constants.ResidencyTraining);
    })
    .Selectable()
    .DataSource(dataSource => dataSource
        .Ajax()
            .Events(events => events.Error("error_handler"))
        .Model(model =>
             {
                 model.Id(p => p.Id);
                 model.Field(p => p.Date).Editable(false);
                 model.Field(p => p.Value).Editable(false);
                 model.Field(p => p.SingleDay).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.HalfDay).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Gross).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.LightMicroscopy).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Pool2X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Pool15X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Pool1X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Pool075X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Pool05X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Pool025X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Gyne1X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Gyne05X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Gyne025X).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.NonG).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.HEM).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Sturgeon).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Biochemistry).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Dermpath).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Colpos).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.Liver).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.QACytology).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.QAHistology).Editable(true).DefaultValue(new List<SelectListItem>());
                 model.Field(p => p.ResidencyTraining).Editable(true).DefaultValue(new List<SelectListItem>());
             })
            .Update(update => update.Action("UpdateTaskSchedule", "Home").Type(HttpVerbs.Post))
            .Read(read => read.Action("TaskSchedule", "Home", @Model.SelectedScheduleId))
         )
)
 <script>
                    function renderMultiSelect(selectListArray) {
                        if (selectListArray != undefined && selectListArray[0] != undefined) {
                            var displayText;
                            $.each(selectListArray, function (index) {
                                if (displayText == undefined) {
                                    displayText = selectListArray[index].Text + ', ';
                                }
                                else {
                                    displayText = displayText + selectListArray[index].Text + ', ';
                                }
                            });
                            return displayText.slice(0, -2);
                        }
                        else {
                            return "";
                        }
                    }
                    function TaskScheduleRefreshGrid(e) {
                        debugger;
                        var grid = $("#TaskScheduleGrid").data("kendoGrid");
                        grid.dataSource.read({ "id": $("#TaskScheduleIdSelector").val() });
                    }

 </script>

 

I have an editor template for most of the columns which is the same for most of the records:

@model List<SelectListItem>
        @(Html.Kendo().MultiSelectFor(x=>@Model)
            .Name("StaffListBiochemistry")
            .BindTo((System.Collections.IEnumerable)ViewData["Staff"])
            .DataTextField("Text")
            .DataValueField("Value")
        )

 

 

3 Answers, 1 is accepted

Sort by
0
App
Top achievements
Rank 1
answered on 23 Nov 2015, 05:47 PM

this happens with Kendo UI version: "2015.2.902"

the chrome kendo client tools dont report any problems. 

0
Accepted
Dimo
Telerik team
answered on 26 Nov 2015, 07:48 AM
Hello,

When you say that the update action is not being called, does this mean that a request is not made at all, or it is made, but does not hit the action method on the server?

Please verify the following:

- The kendo.aspnetmvc.min.js script file is registered on the page after the other Kendo UI scripts (e.g. kendo.all.min.js)
http://docs.telerik.com/kendo-ui/aspnet-mvc/asp-net-mvc-4#include-the-javascript-and-css-files

- A model ID value should be set in the data item, otherwise the Grid will treat the data item as new and will try to call the create action, which is currently not configured. The ID value should be non-default for the used data field type.
http://docs.telerik.com/kendo-ui/framework/datasource/crud#update-local
(see "Note on IDs")

- Finally, compare your implementation with the "Inline editing" example that we provide. The online version is here, but I recommend checking the offline version, which is part of the "UI for ASP.NET MVC" installation:
http://demos.telerik.com/aspnet-mvc/grid/editing-inline

There is also a downloadable project linked at the bottom of this page:
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/ajax-editing

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
App
Top achievements
Rank 1
answered on 27 Nov 2015, 04:48 PM

' A model ID value should be set in the data item, otherwise the Grid will treat the data item as new and will try to call the create action, which is currently not configured. The ID value should be non-default for the used data field type.'

This was the problem and it now posts the request.

Tags
Grid
Asked by
App
Top achievements
Rank 1
Answers by
App
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or