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

Custom Datasource CRUD operations all perform GET requests

2 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ruben
Top achievements
Rank 1
Ruben asked on 05 Oct 2017, 05:30 PM

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 Answers, 1 is accepted

Sort by
0
Ruben
Top achievements
Rank 1
answered on 06 Oct 2017, 12:09 PM
Solution: when the datatype is specified as "jsonp" only GET requests are made.
0
Stefan
Telerik team
answered on 09 Oct 2017, 08:14 AM
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.
Tags
Grid
Asked by
Ruben
Top achievements
Rank 1
Answers by
Ruben
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or