function showCopy(){var arr = []; var data = $(“#PlanDetailGrid”)。data(“ kendoGrid”)。dataSource.data();为(var i
= 0;我
您可以使用此语法
$('#PlanDetailGrid').data('kendoGrid').dataSource.data(result);//result is the data in json format
从控制器中,您可以将结果返回为Json
,并使用像ajax这样的格式将其绑定在一起
$.ajax({
type: "post",
datatype: "json",
contenttype: "application/json",
url: "/Controller/getResult",
success: function (result) {
if (result.Data.length > 0) {
$('#PlanDetailGrid').data('kendoGrid').dataSource.data(result.Data);
}
else {
$("#PlanDetailGrid").data("kendoGrid").dataSource.data([]);
}
}
});
在控制器中
public ActionResult getResult([DataSourceRequest]DataSourceRequest request)
{
//get the result list
DataSourceResult result = lst.ToDataSourceResult(request);//lst is your resultant list
var jsonResult = Json(result, JsonRequestBehavior.AllowGet);
return jsonResult;
}