点击按钮后,点击如何使用javascript发出请求,并使用ajax MVC Kendo UI网格调用读取方法

Upon button click how to make request using javascript and call read method by using ajax MVC Kendo UI grid

本文关键字:Kendo MVC ajax UI 调用 方法 读取 网格 请求 按钮 何使用      更新时间:2023-09-26

由于长期以来我一直在为MVC开发telerik扩展,现在我们公司有了Kendo UI lic.他们想转换我的页面,现在我面临着很多问题。我找到了一些示例,但仍缺少一些代码。

我发现代码

 public ActionResult BulkEdit([DataSourceRequest]DataSourceRequest request)
{        
    var NewAssets = db.TurnaroundDumps;
    DataSourceResult result = NewAssets.ToDataSourceResult(request)
    return Json(result, JsonRequestBehavior.AllowGet);
}

@(Html.Kendo().Grid<PcInventory_v1_1.Models.TurnaroundDump>()
.Name("Grid")
.Columns(columns =>
{
    columns.Bound(p => p.AssetTag);
    columns.Bound(p => p.SerialNumber);
    columns.Bound(p => p.DeptId);
    columns.Bound(p => p.Location);
})
    .DataSource(dataSource => dataSource
        .Ajax() // Specify that the data source is of ajax type
        .Read(read => read.Action("BulkEdit", "Assets")) 
        // Specify the action method and controller name
    ).Pageable()
)

但我在他们创建请求的地方找不到javascript。

事实上,我想在点击按钮时得到我的结果,当用户点击搜索按钮时,我想把请求对象传递给方法,但我不知道如何使用Kendo UI。

感谢

基本上,为了执行对服务器的请求,您应该使用Grid的dataSource对象,更具体地说,是read对象。

$('#gridName').data().kendoGrid.dataSource.read({someExtraParamIfYouWant:"SomeValue"});

上面的代码将到达dataSource声明指定的操作方法,并传递任何值(如果传递任何值)。

页面、筛选器、排序、分组等也将传递给操作方法,DataSourceRequest对象将包含它们。