Hello,
Let me preface this question with the fact that we are very new to List Views and Kendo UI in general. We are developing our project with MVC and using the client side (non-server side wrapper) approach to the Kendo UI List Views. We pass JSON down to the view and render the List View with no problems. We can add list items fine as well. The only issue is when we try to update/delete a record we are not properly returning JSON back to our controller server side. I believe the issue is in our ParameterMap code:
I have tested to ensure that the JSON data in parameter map is valid for the record updated and picks up the change.
Our controller/Action Method for update is actually reached when committing the update but nothing is in the parameter request:
My question is - what is the standard way of passing in JSON to an action method for update? We want to stay away from the server side wrapper in using Kendo UI. We basically want to just pass JSON back and forth between the client and server. If you have a sample project that we could view that demonstrates a client side approach that would be great.
Thanks,
Justin
Let me preface this question with the fact that we are very new to List Views and Kendo UI in general. We are developing our project with MVC and using the client side (non-server side wrapper) approach to the Kendo UI List Views. We pass JSON down to the view and render the List View with no problems. We can add list items fine as well. The only issue is when we try to update/delete a record we are not properly returning JSON back to our controller server side. I believe the issue is in our ParameterMap code:
I have tested to ensure that the JSON data in parameter map is valid for the record updated and picks up the change.
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: 'Read',
dataType: 'json'
},
destroy: {
url: 'Destroy',
dataType: 'json'
},
create: {
url: 'Create',
dataType: 'json'
},
update: {
url: 'Update',
dataType: 'json'
},
parameterMap: function (data, operation) {
if (operation == "update") {
return kendo.stringify(data); //what to return here?
}
}
},
schema: {
data: 'Data',
model: {
id: 'LoanNumber',
fields: {
LoanNumber: 'LoanNumber',
PrimaryCifNumber: 'PrimaryCifNumber',
GrossLoanAmount: 'GrossLoanAmount',
Opit: 'Opit',
RefinanceAmount: 'RefinanceAmount',
LoanLeaseType: 'LoanLeaseType',
RepaymentType: 'RepaymentType',
LoanLeaseTermMonths: 'LoanLeaseTermMonths',
RepaymentFrequency: 'RepaymentFrequency',
PreApproval: 'PreApproval',
CollateralType: 'CollateralType'
}
}
}
});
var listView = $("#LineofCreditsListView").kendoListView({
selectable: true,
navigatable: true,
editable: true,
dataSource: dataSource,
template: kendo.template($("#template").html()),
editTemplate: kendo.template($("#editTemplate").html()),
}).data("kendoListView");
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: 'Read',
dataType: 'json'
},
destroy: {
url: 'Destroy',
dataType: 'json'
},
create: {
url: 'Create',
dataType: 'json'
},
update: {
url: 'Update',
dataType: 'json'
},
parameterMap: function (data, operation) {
if (operation == "update") {
return kendo.stringify(data); //what to return here?
}
}
},
schema: {
data: 'Data',
model: {
id: 'LoanNumber',
fields: {
LoanNumber: 'LoanNumber',
PrimaryCifNumber: 'PrimaryCifNumber',
GrossLoanAmount: 'GrossLoanAmount',
Opit: 'Opit',
RefinanceAmount: 'RefinanceAmount',
LoanLeaseType: 'LoanLeaseType',
RepaymentType: 'RepaymentType',
LoanLeaseTermMonths: 'LoanLeaseTermMonths',
RepaymentFrequency: 'RepaymentFrequency',
PreApproval: 'PreApproval',
CollateralType: 'CollateralType'
}
}
}
});
var listView = $("#LineofCreditsListView").kendoListView({
selectable: true,
navigatable: true,
editable: true,
dataSource: dataSource,
template: kendo.template($("#template").html()),
editTemplate: kendo.template($("#editTemplate").html()),
}).data("kendoListView");
Our controller/Action Method for update is actually reached when committing the update but nothing is in the parameter request:
public void Update(JsonResult request)
{
//update DB
}
{
//update DB
}
Thanks,
Justin