I have looked at several posts in the forum regarding filtering. I want to achieve the following objective:
I have been able to manage the display of the filter row using the ItemCreated event:
On the client side it sort-of works, but there is some odd behavior:
I have to click the filter button three times to get it to show the row (turn on, turn off, turn on and then I see the row). If I use jQuery to hide the .rgFilterRow class it works fine.
The calls to clear the filter appear to generate individual post-backs where I want one call to clear everything. One thought was to use fireCommand and do the clean-up on the server side. In either case I also want to only make the callback if the filter has a value in it (if the results aren't currently filtered there is no point in round tripping).
Thoughts?
- On load if there is no filter value (populated from state) the filter row is hidden and the filter button in the command toolbar is toggled off
- On load if there is a filter value (populated from state) the filter row is show and the filter button in the command toolbar is toggled on
- If the filter button is toggled on, show the filter row (preferably on client-side rather than AJAX round trip)
- If the filter button is toggled off, clear all filters, hide the filter row, and rebind the grid
I have been able to manage the display of the filter row using the ItemCreated event:
if (e.Item is GridFilteringItem && string.IsNullOrEmpty(Grid.MasterTableView.FilterExpression)) |
{ |
e.Item.Display = false; |
} |
else if (e.Item is GridCommandItem && !string.IsNullOrEmpty(Grid.MasterTableView.FilterExpression)) |
{ |
var toolBar = e.Item.FindControl("ToolBar") as RadToolBar; |
(toolBar.FindButtonByCommandName("Filter") as RadToolBarButton).Checked = true; |
} |
On the client side it sort-of works, but there is some odd behavior:
function ToolBar_ClientButtonClicked(sender, args) |
{ |
var button = args.get_item(); |
switch (button.get_commandName()) |
{ |
case 'Filter': |
if (button.get_isChecked()) |
{ |
$find('<%= Grid.ClientID %>').get_masterTableView().showFilterItem(); |
} |
else |
{ |
var masterTableView = $find("<%= Grid.ClientID %>").get_masterTableView(); |
masterTableView.filter("Description", "", Telerik.Web.UI.GridFilterFunction.NoFilter); |
masterTableView.filter("Class", "", Telerik.Web.UI.GridFilterFunction.NoFilter); |
masterTableView.filter("DefaultCategory", "", Telerik.Web.UI.GridFilterFunction.NoFilter); |
masterTableView.hideFilterItem(); |
} |
break; |
} |
} |
I have to click the filter button three times to get it to show the row (turn on, turn off, turn on and then I see the row). If I use jQuery to hide the .rgFilterRow class it works fine.
The calls to clear the filter appear to generate individual post-backs where I want one call to clear everything. One thought was to use fireCommand and do the clean-up on the server side. In either case I also want to only make the callback if the filter has a value in it (if the results aren't currently filtered there is no point in round tripping).
Thoughts?