2017-04-11 9 views
1

を削除するか、私は他のフォームを保存する必要があり、削除して、その機能を保存するidを取得し、渡す追加のパラメータを渡すこと、これらのイベントとidなどの追加のパラメータcreate, update, delete剣道UIは、更新を作成し、作成、更新を行う場合

私は何かhereを見つけましたが、これは正しく表示されませんどのように

私は

$(document).ready(function() { 
        var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service", 
         dataSource = new kendo.data.DataSource({ 
          transport: { 
           read: { 
            url: crudServiceBaseUrl + "/Products", 
            dataType: "jsonp" 
           }, 
           update: { 
            url: crudServiceBaseUrl + "/Products/Update", 
            dataType: "jsonp" 
           }, 
           destroy: { 
            url: crudServiceBaseUrl + "/Products/Destroy", 
            dataType: "jsonp" 
           }, 
           create: { 
            url: crudServiceBaseUrl + "/Products/Create", 
            dataType: "jsonp" 
           }, 
           parameterMap: function(options, operation) { 
            if (operation !== "read" && options.models) { 
             return {models: kendo.stringify(options.models)}; 
            } 
           } 
          }, 
          batch: true, 
          pageSize: 20, 
          schema: { 
           model: { 
            id: "ProductID", 
            fields: { 
             ProductID: { editable: false, nullable: true }, 
             ProductName: { validation: { required: true } }, 
             UnitPrice: { type: "number", validation: { required: true, min: 1} }, 
             Discontinued: { type: "boolean" }, 
             UnitsInStock: { type: "number", validation: { min: 0, required: true } } 
            } 
           } 
          } 
         }); 

        $("#grid").kendoGrid({ 
         dataSource: dataSource, 
         pageable: true, 
         height: 550, 
         toolbar: ["create"], 
         columns: [ 
          { field:"ProductName", title: "Product Name" }, 
          { field: "UnitPrice", title:"Unit Price", format: "{0:c}", width: "120px" }, 
          { field: "UnitsInStock", title:"Units In Stock", width: "120px" }, 
          { field: "Discontinued", width: "120px" }, 
          { command: ["edit", "destroy"], title: " ", width: "250px" }], 
         editable: "popup" 
        }); 
       }); 

以下のように私のグリッドスクリプトを持っている

は、私はそれが非常にSurteの場合、私はJSON.stringifyを使用

return kendo.stringify({ 
    models: options.models, 
    categoryId: categoryIdFromSomewhere 
)}; 

小型ノート区分を返しますが、なるようにこれに単にparameterMap変更return文の内側に

[HttpPost] 
    public JsonResult Add(Product product, int categoryId) 
    { 

    } 

答えて

0

に投稿する必要がありますそれは何か違いがあります。

+0

categoryIdFromSomewhereが0を返したりエラーをスローしたりすると、イベントを停止できますか? – HaBo

+0

申し訳ありませんが、実際にはこれを試みたことはありません...しかし、あなたはいつもクリックイベントの前にそれを確認できます –

関連する問題