Custom Datasource CRUD operations all perform GET requests

3 posts, 0 answers
  1. Ruben
    Ruben avatar
    22 posts
    Member since:
    Sep 2017

    Posted 05 Oct 2017 Link to this post

    Hello all,

    So, as the title states I am having an issue where my grid's CRUD operations all perform GET requests instead of POST, PUT, and DELETE. 

    Here is my grid and datasource: 

    @model ERMgtProgram.Models.ProductViewModels.GradeGroupViewModel
    @{
        ViewBag.Title = "Grade Group";
    }
     
    <h2>@ViewBag.Title</h2>
     
    @(Html.Kendo().Grid<ERMgtProgram.Models.ProductViewModels.GradeGroupViewModel>()
          .Name("gradeGroupGrid")
          .Columns(columns =>
          {
              columns.Bound(c => c.GradeGroups).Width(140);
              columns.Command(command => { command.Edit(); command.Destroy(); }).Width(180);
          })
          .ToolBar(toolbar =>
          {
              toolbar.Create();
          })
          .HtmlAttributes(new { style = "height: 700px;" })
          .Editable(editable => editable.Mode(GridEditMode.PopUp))
          .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(new int[] { 10, 20, 50, 100, 250, 1000 })
            .ButtonCount(5)).Navigatable()
          .Selectable(selectable =>
          {
              selectable.Mode(GridSelectionMode.Multiple);
              selectable.Type(GridSelectionType.Row);
          })
          .Sortable(sortable =>
          {
              sortable.SortMode(GridSortMode.MultipleColumn);
          })
          .Filterable()
          .Scrollable()
          .DataSource(dataSource => dataSource
            .Custom()
            .Batch(true)
            .PageSize(50)
            .Schema(schema => schema.Model(m => m.Id(p => p.GradeID)))
            .Transport(transport =>
            {
                transport.Read(read =>
                   read.Url("http://localhost:62664/api/gradegroup")
                       .DataType("jsonp")
                       .Type(HttpVerbs.Get)
                );
                transport.Create(create =>
                    create.Url("http://localhost:62664/api/gradegroup/create")
                        .DataType("jsonp")
                        .Type(HttpVerbs.Post)
                );
                transport.Update(update =>
                    update.Url("")
                        .DataType("jsonp")
                        .Type(HttpVerbs.Put)
                );
                transport.Destroy(destroy =>
                 destroy.Url("")
                     .DataType("jsonp")
                     .Type(HttpVerbs.Delete)
                );
            })
          )
    )
    <script>
    $(function() {
        var grid = $("#gradeGroupGrid").data("kendoGrid");
     
        grid.dataSource.transport.options.update.url = function (data) {
            return "http://localhost:62664/api/gradegroup/update/" + data.models[0].GradeID;
            }
     
            grid.dataSource.transport.options.destroy.url = function(data) {
            return "http://localhost:62664/api/gradegroup/delete/" + data.models[0].GradeID;
            }
            });
    </script>

     

    My datasource is making calls to a remote WebAPI. The read method works, and the data popluates the grid just fine; but, for my create, update, and destroy methods the datasource sends GET requests even after I specify the "Type" on the various transport methods. I have been at this for some time, and it seems like it should work, but it just doesn't change my request types. 

    I attached a screenshot of the response. 

     

    Any help would be greatly appreciated.

    Ruben

     

  2. Ruben
    Ruben avatar
    22 posts
    Member since:
    Sep 2017

    Posted 06 Oct 2017 Link to this post

    Solution: when the datatype is specified as "jsonp" only GET requests are made.
  3. Stefan
    Admin
    Stefan avatar
    2880 posts

    Posted 09 Oct 2017 Link to this post

    Hello, Ruben,

    I glad that you have found the solution.

    This specific is also listed in our documentation:

    https://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.read.type

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top