Hi, I am using Kendo Grid in my application with Server side sorting. I am sending additional data(object) to my method.
var viewModel = kendo.observable({
param: {
LeadName: "",
LeadPriority: 1,
Notes: "",
Address: "",
City: "",
State: "",
Zip: "",
Booked: 1,
SearchText: ""
}
});
$("#leadsGrdView").kendoGrid({
dataSource: {
type: "aspnetmvc-ajax",
transport: {
read: {
url: "Lead/GetLeadListResult",
data: JSON.parse(JSON.stringify(viewModel.param))
}
},
schema: {
model: {
fields: {
Name: { type: "string", editable: false },
Priority: { type: "string", editable: false },
Notes: { type: "string" },
Booked: { type: "checkbox", editable: false },
Address: { editable: false },
Id: { type: "int" }
}
},
total: "Total",
data: "Data"
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
scrollable: false,
sortable: true,
groupable: false,
pageable: { buttonCount: 4 },
columns: [{ template: '<a href="/Lead/LeadDetail/#=Id#">#=Name#</a>', field: "Name", title: "Lead Name", width: "30%" },
{ field: "Priority", title: "Lead Priority", width: "20%" },
{
field: "Address",
title: "Address", width: "30%",
template: '<span> #=Address.Address1#, #=Address.City# #=Address.State# </span>'
},
{ field: "Notes", title: "Notes", width: "30%" },
{
field: "Booked",
template: '<input type="checkbox" #= Booked ? "checked=checked" : "" # ></input>'
}
]
});
I am using viewModel.param object in my view. I am sending viewModel.param object as an additional data to the method.I can able to retrieve additional data to my method. This works as expected till now. After viewModel.param object variables are modified and if I try to sort any column, the updating additional data is not being sent to method, instead it sends the initial data when Kendo grid is initially loaded.
How can I send the updated additional data in Server side sorting? Is there any better approach than this to accomplish my requirement.
All I need is to send the updated object I have in my javascript to the method in the controller when using server side sorting.
Any help will be greatly appreciated
var viewModel = kendo.observable({
param: {
LeadName: "",
LeadPriority: 1,
Notes: "",
Address: "",
City: "",
State: "",
Zip: "",
Booked: 1,
SearchText: ""
}
});
$("#leadsGrdView").kendoGrid({
dataSource: {
type: "aspnetmvc-ajax",
transport: {
read: {
url: "Lead/GetLeadListResult",
data: JSON.parse(JSON.stringify(viewModel.param))
}
},
schema: {
model: {
fields: {
Name: { type: "string", editable: false },
Priority: { type: "string", editable: false },
Notes: { type: "string" },
Booked: { type: "checkbox", editable: false },
Address: { editable: false },
Id: { type: "int" }
}
},
total: "Total",
data: "Data"
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
scrollable: false,
sortable: true,
groupable: false,
pageable: { buttonCount: 4 },
columns: [{ template: '<a href="/Lead/LeadDetail/#=Id#">#=Name#</a>', field: "Name", title: "Lead Name", width: "30%" },
{ field: "Priority", title: "Lead Priority", width: "20%" },
{
field: "Address",
title: "Address", width: "30%",
template: '<span> #=Address.Address1#, #=Address.City# #=Address.State# </span>'
},
{ field: "Notes", title: "Notes", width: "30%" },
{
field: "Booked",
template: '<input type="checkbox" #= Booked ? "checked=checked" : "" # ></input>'
}
]
});
I am using viewModel.param object in my view. I am sending viewModel.param object as an additional data to the method.I can able to retrieve additional data to my method. This works as expected till now. After viewModel.param object variables are modified and if I try to sort any column, the updating additional data is not being sent to method, instead it sends the initial data when Kendo grid is initially loaded.
How can I send the updated additional data in Server side sorting? Is there any better approach than this to accomplish my requirement.
All I need is to send the updated object I have in my javascript to the method in the controller when using server side sorting.
Any help will be greatly appreciated