使用 Telerik Rad Grid 时如何知道何时使用滤波器?
我进行了全站搜索,将搜索结果放入多个 Rad 网格中。当网格中没有行时,我隐藏网格。我有一个特殊的情况,当用户应用列过滤器并且没有结果时,我不想隐藏网格。我希望用户能够修改列过滤器,尽管没有结果。我当前的代码隐藏网格并且不允许用户修改列过滤器。
有没有办法知道何时从客户端在 RadGrid 上应用过滤器?
我的客户端代码如下所示:
function OnClientDataBound(sender, args) {
toggleLoadingPanel(sender.get_id(), false);
var grid = $find(sender.ClientID);
var masterTable = grid.get_masterTableView();
var rows = masterTable.get_dataItems();
// I want to be able to determine if the grid has filters applied here
// so that I don't hide it in this case.
if (rows == 0) {
var words = sender.ClientID.split("_");
var divName = "#div" + words[words.length-1];
jQuery(divName).hide();
}
}
I have site wide search where I put the search results into several Rad Grids. I hide the grid when there are no rows in the grid. I have a special case scenario that I don't want to hide the grid when the user applies column filters and there are no results. I want the user to be able to modify the column filters despite the fact that there are no results. My current code hides the grid and doesn't allow the user to modify the column filters.
Is there a way to know when filters are applied on the RadGrid from the client side?
My client code looks like:
function OnClientDataBound(sender, args) {
toggleLoadingPanel(sender.get_id(), false);
var grid = $find(sender.ClientID);
var masterTable = grid.get_masterTableView();
var rows = masterTable.get_dataItems();
// I want to be able to determine if the grid has filters applied here
// so that I don't hide it in this case.
if (rows == 0) {
var words = sender.ClientID.split("_");
var divName = "#div" + words[words.length-1];
jQuery(divName).hide();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
服务器端(以防万一您可能会发现它有用):
如果您有一个 Column 对象,那么您可以使用 CurrentFilterFunction 和 CurrentFilterValue 来获取/设置该列的过滤器。
如果您想一次性检查整个网格,则可以使用
yourRadGridObject.MasterTableView.FilterExpression
客户端:
get_filterExpressions()
Server side (just in case you may find it useful):
If you have a
Column
object then you can use theCurrentFilterFunction
andCurrentFilterValue
to get/set that column's filter.If you want to inspect the entire grid in one go then you can use
yourRadGridObject.MasterTableView.FilterExpression
Client side:
get_filterExpressions()