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

Grid Filter using RadComboBox Checkbox- FilterExprerssion

1 Answer 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 10 Feb 2012, 04:19 PM
Hi,

i'm trying to filter a Grid using the RadComboBox with Checkbox's.

I could able to get the selected items vlaues in the server side.... but unable to apply the filter to the Grid.
i guess, Problem is with the Filter Expression. No errors/Exceptions

sample code... on click of a button inside the RadComboBox <FooterTemplate> ....
<<ascx.cs>>
     rgAccounts.MasterTableView.FilterExpression = (string)ViewState["FilterExpr"];
     rgAccounts.MasterTableView.Rebind();

where computed value of :
        (string)ViewState["FilterExpr"] =  "(AccountNums] IN (1203, 2344)"

 Pls let me know how to fix this.



1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Feb 2012, 10:49 AM
Hello,

Try the following code.
C#:
protected void btn1_Click(object sender, EventArgs e)
   {
       Button btn = (Button)sender;
       string checkedText="";
       RadComboBox combo = (RadComboBox)btn.Parent.Parent;
       var collection = combo.CheckedItems;
       foreach (var item in collection)
       {
           checkedText += item.Text + ",";
       }
       string filterExpression;
       string t = checkedText.Trim(',');
       filterExpression = "(([ProductID] = '" + t[0] + "') OR ([ProductID] = '" + t[2] + "'))";// for 2 selected items
       RadGrid1.MasterTableView.FilterExpression = filterExpression;
       RadGrid1.MasterTableView.Rebind();
 }
Note: Set EnableLinqExpressions as False.

Thanks,
Princy.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or