I have a customize Read function for kendo grid ....
public virtual async Task<ActionResult> Read([DataSourceRequest] DataSourceRequest request,
RecordStatus? recoredStatus){ // code here }
now I want refresh my grid by using record status in kendo with jquery
<script type="text/javascript">
function viewButtonClickHandler(e) {
alert(e.Id)
$('#Grid').data('kendoGrid').dataSource.read(e.Id);
$('#Grid').data('kendoGrid').refresh();
}
but how I send this additional parameter ( recordStatus )in read function !? can I do this !?
So if you are using Kendo MVC UI you can use the Data property for the Read method of DataSource . So the client side method DataHandlerName will execute while you are requesting for the read action, by using-
$('#Grid').data('kendoGrid').dataSource.read();
You can easily handle the client side script. Your Server Side code will be following for Kendo GRID,
.DataSource(dataSource => dataSource.Ajax().ServerOperation(false).Read(r=> r.Action("ActionName","ControllerName").Type(HttpVerbs.Post).Data("DataHandlerName")))
And your client side code will be-
<script>
function DataHandlerName() {
//your code will goes here
var request={
id:1
};
return request ;
}
</script>
And Your Action Mehtod will be,
public ActionResult ActionName([DataSourceRequest] DataSourceRequest request,int id){}
If I understood correctly you just need this. And also please take a look to the link. It may can helps you.
function onSomeButtonClick(){
grid_.dataSource.read({q:"test"});
}
http://www.telerik.com/forums/how-to-refresh-a-grid-with-parameters-dc0f416ce08a
Using Purely java script this is how you can send params to read method
$('#grid').data('kendoGrid').dataSource.Read({id:e.Id});
$('#Grid').data('kendoGrid').refresh();
On Server Side you need this.
public ActionResult Products_Read([DataSourceRequest] DataSourceRequest request,int id){}
If you are using MVC based grid telerik forum already has example on how to do use read to send extra parameters .
http://www.telerik.com/forums/pass-additional-parameters-to-read-ajax-datasource-method---mvc