This is a migrated thread and some comments may be shown as answers.

Filtering Multiple Columns at once

1 Answer 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danielle
Top achievements
Rank 1
Danielle asked on 06 Aug 2008, 06:38 AM
Hi,

I'm using CustomFilterColumns in my RadGrid (as per the examples provided from Telerik). Because I don't want a postback to occur everytime a new filter selection occurs, I've set the AutoPostBack to false (this is within the CustomFilterColumn class) and created a button with CommandName="Filter" (see below) in the hope that when the user selects one (or many) filters, then clicks on the button, the appropriate filtering will be applied.

What I'm finding however, is that if I have more than 1 column with a filter value selected in the dropdown list and then I click on the "Apply Filter" button, only the first column's (from the LHS) filter gets applied to the grid and any subsequent filters are disregarded. This happens the first time. When I continue to select another filter (after the first filter is applied) and click on the "Apply Filter" button, then both these filters are applied correctly. I.e. The filterexpression is "([column1] = 'value1' AND [column2] = 'value2').

I have tried enabling view state as well as the EnableColumnsViewState property however this has not helped.

I'd appreciate any ideas/solutions for this.

Thanks and Regards,

Danielle.


<

CommandItemTemplate>

<asp:Button Runat="server" ID="ClearAllFiltersLinkButton"Text="Clear All Filters" CommandName="ClearFilters" />

<asp:Button Runat="server" ID="ApplyFilterButton"Text="Apply Filtering" CommandName="Filter" />

</CommandItemTemplate>


1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 06 Aug 2008, 11:47 AM
Hello Danielle,

The behavior you are getting is expected, as RadGrid's Filter command is by default designed to work with only one column at a time. Therefore, subsequent activation of the command forms the correct filter. What you need to do to solve this issue, is not use the "Filter" command (or the default filter command), but change to your own filter command (e.g. "MultiFilter"). Then in the ItemCommand event handler, you can check for this command, and manually construct the filter expression to pass to RadGrid. After that, rebinding should have your RadGrid filtered by the custom filter expression. Please check this out.

All the best,
Veli
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Danielle
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or