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

filter expressions as a string?

3 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 02 Feb 2009, 05:54 PM
heya.. I know I saw this in use in one of the demos but can't find it any longer. I have a grid with the following
<telerik:radgrid id="Radgrid1" FilterExpression= "[column] = 'TextValue' ....>
I also have a checkbox control on the page to quicly just filter out the items that have a count greater than zero.

Is there a reason I can't build a filter expression using regualar t-sql?


code snippet.

Protected Sub appfilter_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles appfilter.CheckedChanged  
 
        RadGrid1.MasterTableView.FilterExpression = Nothing 
        If appfilter.Checked = True Then  
                    RadGrid1.MasterTableView.FilterExpression = "(([Icount] > '0' and [ActivityStatus] = 'Vacant') or [Ecount] > '0')" ' consider the first two items or consider the third.  
            RadGrid1.MasterTableView.Rebind()  
 
        Else  
            RadGrid1.MasterTableView.FilterExpression = "([ActivityStatus] = 'Vacant')" 
            RadGrid1.MasterTableView.Rebind()  
        End If  
 
    End Sub 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Feb 2009, 06:49 AM
Hi Mac,

I hope you are trying to set the FilterExpression for the Grid in the aspx. If so try setting it as shown below.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" Skin="WebBlue"     AllowSorting="true"   PagerStyle-HorizontalAlign="right" AllowMultiRowSelection="true" DataSourceID="SqlDataSource1"   > 
                <MasterTableView FilterExpression="[ActivityStatus] = 'Vacant'"  TableLayout="Fixed"     DataSourceID="SqlDataSource1"


Thanks
Shinu
0
mac
Top achievements
Rank 1
answered on 04 Feb 2009, 04:43 PM
your example works as expected however my question was in dealing with multiple columns, not just one.
ie. (([column1] = 'Alpha' and [thecount] > 0) OR [columnb] = 'some other value'). when written as is, the filter is completely ignored.
Question: How to formulate multi column filter expression?
Question: Is the column related to the Datasource Column Name or the Grid Unique Name or the Grid DataField Name?

Thank you for your assistance in this.
0
Yavor
Telerik team
answered on 05 Feb 2009, 08:53 AM
Hello mac,

Attached to this message, is a small application, which handles a similar task.
I hope it helps.

Kind regards,
Yavor
the Telerik team

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