简体   繁体   中英

How to know when filters are used when using Telerik Rad Grid?

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();
            }

        }

Server side (just in case you may find it useful):

If you have a Column object then you can use the CurrentFilterFunction and CurrentFilterValue 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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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