Mark Fila
Mark Fila

Reputation: 25

kendo ui model is always null in parameter map

Im using kendo ui grid and everything is working fine except for update. When i click on the reviewed column the field changes to a check box and i can edit it, and the update gets called but no data is passed in the put request. If i put a breakpoint in the parameter map function the model is null. Javascript code is below:

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
     });
 });

Upvotes: 1

Views: 2399

Answers (1)

Atanas Korchev
Atanas Korchev

Reputation: 30671

The models field is available only when the batch option is set to true. This doesn't seem to be the case here. The model fields are exposed in the data parameter when batch is set to false.

Upvotes: 2

Related Questions