2013-10-03 63 views
1

我使用kendo ui網格,除了更新以外,一切正常。當我點擊已審覈的專欄時,該欄位變爲複選框,我可以對其進行編輯,並且更新被調用,但沒有數據在放置請求中傳遞。如果我在參數映射函數中放置斷點,則模型爲空。 Javascript代碼低於:kendo ui模型在參數映射中始終爲空

var selfPayDataSource = new kendo.data.DataSource({ 
    serverFiltering: true, // <-- Do filtering server-side 
    serverPaging: true, // <-- Do paging server-side 
    serverSorting: true, 
    autoSync: true, 
    pageSize: 100, 
    batch:false, 
    //filter: generateDsFilter(), 
    type: 'odata', // <-- Include OData style params on query string. 
    sortable: { 
     mode: "multiple", 
     allowUnsort: true 
    }, 
    pageable: { 
     refresh: true 
    }, 
    schema: { 
     data: function (data) { 
      return data.Items; // <-- The result is just the data, it doesn't need to be unpacked. 
     }, 
     total: function (data) { 
      return data["Count"]; // <-- The total items count is the data length. 
     }, 
     model: { 
      id: "SelfPayId", 
      fields: { 
       resp_ind: { type: "string", editable: false }, 
       cstsv_resolved: { type: "string", editable: false }, 
       cstsv_rep: { type: "string", editable: false }, 
       cstsv_comp_date: { type: "string", editable: false }, 
       region: { type: "string", editable: false }, 
       db: { type: "string", editable: false }, 
       personid: { type: "string", editable: false }, 
       legacyid: { type: "string", editable: false }, 
       account__: { type: "string", editable: false }, 
       deceased: { type: "string", editable: false }, 
       patient_name: { type: "string", editable: false }, 
       account_balance: { type: "number", editable: false }, 
       pat_last_paid_date: { type: "date", editable: false }, 
       pat_last_paid_amt: { type: "number", editable: false }, 
       acct_stat: { type: "string", editable: false }, 
       bill_type: { type: "string", editable: false }, 
       acct_score: { type: "number", editable: false }, 
       tu_status: { type: "string", editable: false }, 
       scoring: { type: "number", editable: false }, 
       coll_ltr: { type: "string", editable: false }, 
       HighestPriPlan: { type: "string", editable: false }, 
       HighestSecPlan: { type: "string", editable: false }, 
       HighestTerPlan: { type: "string", editable: false }, 
       Max_DOS_Aging_Group: { type: "string", editable: false }, 
       Reviewed: { type: "boolean", editable: true }, 
       Collector_Name: { type: "string", editable: false} 
      } 
     } 
    }, 
    transport: { 
     read: { 
      url: "/api/SelfPayData/Get", // <-- Get data from here 
      dataType: "json" // <-- The default was "jsonp" 
     }, 
     update: { 
      url: "/api/SelfPayData/PUT", 
      dataType: "json", // <-- The default was "jsonp" 
      contentType: "application/json; charset=utf-8", 
      type: "PUT" 
     }, 
     parameterMap: function (data, operation) { 

      if (operation != "read") { 

       return JSON.stringify(data.models); 
      } else { 
       var paramMap = kendo.data.transports.odata.parameterMap(data); 

       var orderBy = paramMap.$orderby; 

       if (orderBy == undefined) { 
        orderBy = "account__"; 
       }else { 
        orderBy = orderBy + ",account__"; 
       } 

       paramMap.$orderby = orderBy; 

       var filter = paramMap.$filter; 

       if (filter == null || filter == '') { 
        delete paramMap.$filter; 
       } 

       delete paramMap.$format; // <-- remove format parameter. 

       return paramMap; 
      } 
     } 
    } 
}); 


$(function() { 
    $("#grid").kendoGrid({ 
     sortable: true, 
     pageable: true, 
     scrollable: true, 
     resizable: true, 
     editable: true, 
     navigatable: true, 
     filterable: { 
      extra: false, 
      operators: { 
       string: { 
        startswith: "Starts with", 
        eq: "Is equal to", 
        neq: "Is not equal to" 
       } 
      } 
     }, 
     columns: [ 
        { 
         field: "cstsv_resolved", 
         title: "Cstsv Resolved", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "cstsv_rep", 
         title: "Cstsv Rep", 
         width: "8em", 
         filterable: true 
        }, 
        { 
         field: "cstsv_comp_date", 
         title: "Cstsv Comp Date", 
         width: "6em", 
         filterable: true 
        }, 
        { 
         field: "region", 
         title: "Region", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "db", 
         title: "DB", 
         width: "4em", 
         filterable: true 
        }, 
        { 
         field: "personid", 
         title: "Person ID", 
         width: "6em", 
         filterable: true 
        }, 
        { 
         field: "legacyid", 
         title: "Legacy ID", 
         width: "6em", 
         filterable: true 
        }, 
        { 
         field: "account__", 
         title: "Account #", 
         width: "6em", 
         filterable: true 
        }, 
        { 
         field: "deceased", 
         title: "Deceased", 
         width: "5.2em", 
         filterable: true 
        }, 
        { 
         field: "patient_name", 
         title: "Patient Name", 
         width: "6em", 
         filterable: true 
        }, 
        { 
         field: "account_balance", 
         title: "Account Balance", 
         width: "5em", 
         filterable: true, 
         format: "{0:c2}" 
        }, 
        { 
         field: "pat_last_paid_date", 
         title: "Pat Last Paid Date", 
         width: "6em", 
         format: "{0: MM-dd-yyyy}", 
         filterable: true 
        }, 
        { 
         field: "pat_last_paid_amt", 
         title: "Pat Last Paid Amt", 
         width: "6em", 
         filterable: true, 
         format: "{0:c2}" 
        }, 
        { 
         field: "acct_stat", 
         title: "Acct Stat", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "bill_type", 
         title: "Bill Type", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "acct_score", 
         title: "Acct Score", 
         width: "4em", 
         filterable: true 
        }, 
        { 
         field: "tu_status", 
         title: "TU Status", 
         width: "6em", 
         filterable: true 
        }, 
        { 
         field: "scoring", 
         title: "Scoring", 
         width: "4em", 
         filterable: true 
        }, 
        { 
         field: "coll_ltr", 
         title: "Coll Ltr", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "HighestPriPlan", 
         title: "Pri Plan", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "HighestSecPlan", 
         title: "Sec Plan", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "HighestTerPlan", 
         title: "Ter Plan", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "Max_DOS_Aging_Group", 
         title: "DOS Aging Group", 
         width: "5em", 
         filterable: true 
        }, 
        { 
         field: "Reviewed", 
         title: "Reviewed", 
         width: "10em", 
         filterable: true 
        }, 
        { 
         field: "Collector_Name", 
         title: "Collector Name", 
         width: "10em", 
         filterable: true 
        } 
        ], 
     dataSource: selfPayDataSource 
    }); 
}); 

回答

2

models場只有當batch選項設置爲true可用。這似乎並非如此。當batch設置爲false時,模型字段將暴露在data參數中。