2013-02-18 2 views
2

Я размещаю веб-сетку kendoui, и она не отправляет данные, и я не вижу, что я делаю, отличная от sample, которая терпит неудачу. Я отправляю к контроллеру, но это либо пустой (если партия: правда или нулевое значение, если партия: ложь)Kendo grid post и delete отправить null в контроллер

var crudServiceBaseUrl = "api/Certifications/", 
       dataSource = new kendo.data.DataSource({ 
        transport: { 
         read: { 
          url: crudServiceBaseUrl + member.id, 
          dataType: "json" 
         }, 
         update: { 
          url: crudServiceBaseUrl, 
          type: "Post", 
          dataType: "json" 
         }, 
         destroy: { 
          url: crudServiceBaseUrl, 
          type: "Delete", 
          contentType: "application/json; charset=utf-8", 
          dataType: "json" 
         }, 
         create: { 
          url: crudServiceBaseUrl, 
          type: "Post", 
          dataType: "json" 
         }, 
         parameterMap: function (options, operation) { 
          if (operation !== "read" && options.models) { 
           return {models: kendo.stringify(options.models)}; 
          } 
         } 
        }, 
        editable: { //disables the deletion functionality 
        update: true, 
        destroy: true 
        }, 
       batch: true, 
        pageSize: 30, 
        schema: { 
         model: { 
          id: "Id", 
          fields: { 
           Id: { editable: false, nullable: true }, 
           MemberId: { editable: false, nullable: true }, 
           Name: { validation: { required: true} }, 
           AuthorityName: { validation: { required: true} }, 
           StartDate: { type: "date", validation: { required: true} }, 
           EndDate: { type: "date" } 
          } 
         } 
        } 
       }); 

       $("#certifications").kendoGrid({ 
       dataSource: dataSource, 
       pageable: true, 
       height: 300, 
       toolbar: ["create"], 
       columns: [ 
        { field: "Name", title: "Product Name", width: 250 }, 
        { field: "AuthorityName", title: "Authority", format: "{0:c}", width: "140px" }, 
        { field: "StartDate", title: "Earned", template: '#= kendo.toString(StartDate,"MM/dd/yyyy") #', width: 50 }, 
        { field: "EndDate", title: "Expired", template: '#= kendo.toString(EndDate,"MM/dd/yyyy") #', width: 50 }, 
        { command: ["edit", "destroy"], title: " ", width: "130px" }], 
       editable: "popup" 
      }); 

веб апи:

public Certification DeleteCertification(CertificationVm cert) 
     { 
      var model = Uow.Certifications.Get(cert.Id); 
      if (model == null) 
       throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NoContent)); 
      Uow.Certifications.Delete(model); 
      Uow.Commit(); 
      return model; 
     } 
+0

Скорее всего, ваш вопрос является своего рода http://stackoverflow.com/questions/22622061/why-are-my-kendogrid-update-parameters-always-null -in-the-controller/24261775 # 24261775, вы можете найти справку – Gyanesh

ответ

8

Я понял это, хотя я должен был уйти из примера http://demos.kendoui.com/web/grid/editing-popup.html

Исправление было добавить тип содержимого, правильно использовать тип данных: «» JSON, как отмечалось выше, переход от партии: истинное к партии ложь и изменить карту параметра в ниже

destroy: { 
            url: crudServiceBaseUrl, 
            type: "Delete", 
            contentType: "application/json; charset=utf-8", 
            dataType: "json" 
           }, 



parameterMap: function (model, operation) { 
            if (operation !== "read" && model) { 
             return kendo.stringify(model) ; 
            } 
           } 
1

Там нет такого понятия, как JSONP + POST - обсуждается here. Не используйте jsonp, если вы действительно не знаете, зачем вам это нужно.

+0

Хороший улов, и вы совершенно правы, я исправил свой пример, но delete met hod был настроен правильно. Я понял это, после того, как ушел. Однако это был не ответ. Я отправлю правильный ответ ниже. –

Смежные вопросы