Kendo grid how to pass additional parameter from java script
Finally i got the answer my own and it is :
$('#grid').data('kendoGrid').dataSource.read({name:value})
Sorry for the terrible late at the party, but i've got some special cake that you may find tasty:
function readData()
{
return {
anagId: selectedItem.ID
};
}
$("#grid").kendoGrid({
dataSource: {
type: "ajax",
transport: {
read: {"url":"@Url.Action("RecordRead", "Tools")","data":readData}
}
[ rest of the grid configuration]
I came across this code by inspecting the code generated by Kendo Asp.Net MVC helpers.
I don't know if this is a further implementation that didn't exist at the age of the post, but this way looks really the most flexible compared to the other answers that i saw. HTH
Try this:
Add this to your grid read function or any CRUD operation:
.Read(read => read.Action("ReadCompanyService", "Admin").Data("CompanyServiceFilter"))
Add javascript:
function CompanyServiceFilter() { return { company: $("#ServiceCompany").val() } }
In your controller:
public ActionResult ReadCompanyService([DataSourceRequest]DataSourceRequest request, string company) { var gridList = repository.GetCompanyServiceRateList(company); return Json(gridList.ToDataSourceResult(request)); }
Please note, only string type data is allowed to be passed on read, create, update and delete operations.