传递参数的Telerik asp.net mvc的网格 [英] Passing parameters to telerik asp.net mvc grid

查看:183
本文介绍了传递参数的Telerik asp.net mvc的网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的Telerik asp.net的MVC格,需要根据用户输入在不同的文本框的搜索条件进行填充。网格是利用AJAX方法来加载自己最初并做分页。

1如何传递搜索参数的网格,以便它发送那些参数每次它调用响应于用户点击另一页的AJAX方法转到数据在该网页上?

我读了Telerik的用户指南,但它并没有提到这种情况。我已经能够做到上述的唯一方法是通过使用jQuery的参数并重新绑定()方法在客户端。问题是,我不知道这是否是合格甚至以后的更新将始终工作参数的官方的方式。 我发现这个职位这种方法对Telerik的网站:链接文本

我要传递多个参数。当由网格的Telerik称为在控制器的动作方法再次运行该查询基于所述搜索参数。

下面是我的code的一个片段:

  $(#searchButton)。点击(函数(){
    VAR电网= $(#发票)的数据(tGrid')。

    VAR startSearchDate = $(#StartDatePicker输入)VAL()。
    。VAR endSearchDate = $(#EndDatePicker输入)VAL();

    grid.rebind({startSearchDate:startSearchDate,
                    endSearchDate:endSearchDate
                });
});
 

解决方案

所以根据的Telerik推荐的方法是设定参数的onDataBinding事​​件。

 函数onGridBinding(五){
如果(cancelGridBinding){
    // ...
}
其他 {
    VAR searchValue ='东西';
    e.data = {搜索:searchValue};
}
 

}

I have a telerik asp.net mvc grid which needs to be populated based on the search criteria the user enters in separate text boxes. The grid is using ajax method to load itself initially as well as do paging.

How can one pass the search parameters to the grid so that it sends those parameters "every time" it calls the ajax method in response to the user clicking on another page to go to the data on that page?

I read the telerik's user guide but it does not mention this scenario. The only way I have been able to do above is by passing the parameters to the rebind() method on client side using jquery. The issue is that I am not sure if it is the "official" way of passing parameters which will always work even after updates. I found this method on this post on telerik's site: link text

I have to pass in multiple parameters. The action method in the controller when called by the telerik grid runs the query again based on the search parameters.

Here is a snippet of my code:

$("#searchButton").click(function() {
    var grid = $("#Invoices").data('tGrid');

    var startSearchDate = $("#StartDatePicker-input").val();
    var endSearchDate = $("#EndDatePicker-input").val();

    grid.rebind({ startSearchDate: startSearchDate ,
                    endSearchDate: endSearchDate
                });
});

解决方案

So according to Telerik "recommended approach is to set the arguments in the onDataBinding event".

function onGridBinding(e) {
if (cancelGridBinding) {  
    // ...
}
else {
    var searchValue = 'something';
    e.data = { search: searchValue };
}

}

这篇关于传递参数的Telerik asp.net mvc的网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆