简体   繁体   English

如何在控制器上检测Kendo Grid MVC初始绑定

[英]How to detect Kendo Grid MVC initial binding on controller

I have a Kendo grid : 我有一个剑道网格:

@(Html.Kendo().Grid<MyVm>().Name("grid").Columns(columns =>
  ...
.DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(p => p.Id))
        .Read(read => read.Action("List", "MyController", new { id = Model.Id }).Type(HttpVerbs.Get)))

On my controller I have : 在我的控制器上,我有:

public JsonResult List([DataSourceRequest] DataSourceRequest request, int id)
{ 
     //if (FIRST/INITIAL LOADING) ?????
     ...
}

How can I check on controller if its the initial loading/binding? 如何检查控制器的初始加载/绑定情况?

Thanks 谢谢

You can add a Data method to your read call which will use a js function that will return a global variable that's set true onLoad and sets it false. 您可以将Data方法添加到您的read调用中,该方法将使用js函数,该函数将返回设置为true onLoad并将其设置为false的全局变量。 Then every time you read data it will send IsFirstRead parameter 然后,每次读取数据时,它将发送IsFirstRead参数

.Read(read => read.Action("List", "MyController", new { id = Model.Id }).Type(HttpVerbs.Get)).Data("isFirstRead"))

function isFirstRead() {
    if (firstTime) {
        firstTime = false;
        return true;
    }
    else
        return false;
}

public JsonResult List([DataSourceRequest] DataSourceRequest request, int id, bool isFirstTime)
{ 
     //if (isFirstTime) ?????
     ...
}

GoodLuck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM