I need to apply filtering for a column in my RadGrid. The column is an int column, and the user must be able to filter multiple selections. I want to do something like this: select * from <table> where num in (X,Y,Z).
How can I get this filtering functionality?
EDIT:
I followed an example on http://www.telerik.com/help/aspnet-ajax/grdcustomoptionforfiltering.html to add custom filtering, and this is what I came up with.
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == RadGrid.FilterCommandName) |
| { |
| Pair filterPair = (Pair)e.CommandArgument; |
| switch (filterPair.Second.ToString()) |
| { |
| case "vendNum": |
| TextBox tbPattern = (e.Item as GridFilteringItem)["vendNum"].Controls[0] as TextBox; |
| if (tbPattern.Text.Contains(",")) |
| { |
| string[] values = tbPattern.Text.Split(','); |
| if (values.Length >= 2) |
| { |
| e.Canceled = true; |
| StringBuilder newFilter = new StringBuilder(); |
| for (int i = 0; i < values.Length; i++) |
| { |
| if (i == values.Length - 1) |
| newFilter.Append("([vendNum]='" + values[i] + "')" ); |
| else |
| newFilter.Append("([vendNum]='" + values[i] + "') OR "); |
| } |
| if (RadGrid1.MasterTableView.FilterExpression == "") |
| RadGrid1.MasterTableView.FilterExpression = newFilter.ToString(); |
| else |
| RadGrid1.MasterTableView.FilterExpression = "((" + RadGrid1.MasterTableView.FilterExpression + ") AND (" + newFilter.ToString() + "))"; |
| RadGrid1.Rebind(); |
| } |
| } |
| break; |
| default: |
| break; |
| } |
| } |
| } |
This is giving me an "Expression Expected" error when I try to filter that column. Anyone have an idea as to why that is?
Thanks,
Aaron