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

Radgrid filter does not properly work when FilterExpression is programmatically changed

1 Answer 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mario
Top achievements
Rank 1
Mario asked on 23 Sep 2013, 04:00 PM
Hello,
I use Radgrid for viewing my web application logs. These logs has 7 different types, so in order to filter the grid, I added before radgrid, a CheckBoxList that contains the ID of log types. So the code is something like this:

       For Each lItem As ListItem In chkTipologieLog.Items
            If lItem.Selected Then
                lstrFiltro += "(CodTipologiaLog = " + lItem.Value.ToString + ") OR"
            End If
        Next
 
           rdgrid.Mastertableview.FilterExpression = "(" + lstrFiltro + ")"
           rdgrid.Mastertableview.rebind

The code is more than this one, it consider also the filter operations made by radgrid filter columns, so, in checbox select index changed, the rdgrid.Mastertableview.FilterExpression could be like this:
"(iif(Azienda == null, "", Azienda).ToString().ToUpper() = "Azienda 1".ToUpper()) AND ((CodTipologiaLog = 2) OR(CodTipologiaLog = 3))"

It perfectly works if you choose a filter in the filterrow (in this case Azienda = Azienda 1) and THEN you select one or more items in checlistbox.

BUT... if you select one checkbox and then you choose a filter in the filter-row, the filters programmatically created is not taken in consideration. I tried to catch ItemCommand event of radgrid and, when FilterCommandName is fired, recalculate the filters obtained by checboxes. In this case, even if filterexpression contains the correct query, rows are filtered only for Azienda = Azienda 1 query.

The same if I recaculate the filter on every postback.

Where am I wrong?

Thanks
Mario

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 26 Sep 2013, 10:32 AM
Hi Mario,

When you filter with the default grid's column filters (CommandName "Filter") and in order to apply the custom filtering, you will have cancel the command (e.Canceled = true), assign the new FilterExpression and rebing the grid.

Have in mind that you will have to obtain the filter expression of the default filters and apply it to your custom expression in order to combine the two filtering methods.

Hope that helps.

 

Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Mario
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or