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

[Solved] Dynamic colum enable/disable search

5 Answers 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chetan
Top achievements
Rank 1
Chetan asked on 03 Apr 2013, 07:54 AM
Hello,

I am using Radgrid. I have dynamically added columns in this grid like mentioned below. I wanted to add filter for some of the columns. What is the way to enable this so that some columns will have filter. I am using custom paging so how to make filter on complete records instead of current page records? Also there is column for phone where records are displayed as (123)-456-1234. If user enters 12345.. then also it should search the phone.      
GridBoundColumn boundColumn1 = new GridBoundColumn();
RadGrid1.MasterTableView.Columns.Add(boundColumn1);
boundColumn1.ItemStyle.Wrap = false;
boundColumn1.DataField = DataField;
boundColumn1.SortExpression = DataField;
boundColumn1.HeaderText = HeaderText;

5 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Apr 2013, 11:12 AM
Hello,

// Allow Column for all column
       RadGrid1.AllowFilteringByColumn = true;
 
       GridBoundColumn boundColumn1 = new GridBoundColumn();
       RadGrid1.MasterTableView.Columns.Add(boundColumn1);
       boundColumn1.ItemStyle.Wrap = false;
       boundColumn1.DataField = DataField;
       boundColumn1.SortExpression = DataField;
       boundColumn1.HeaderText = HeaderText;
       // Disable filter to this column
       boundColumn1.AllowFiltering = false;


Thanks,
Jayesh Goyani
0
Chetan
Top achievements
Rank 1
answered on 04 Apr 2013, 05:59 AM
Thank you Jayesh, it worked for me. I also wanted to know that there is column for phone where records are displayed as (123)-456-1234. If user enters 12345.. then also it should search the phone. Any thoughts on this?
0
Shinu
Top achievements
Rank 2
answered on 04 Apr 2013, 06:49 AM
Hi,

One suggestion is that you can use GridMaskedColumn for the purpose .This column type is for values that fit a specific format. Set the Mask property to specify an edit mask that defines the valid values. Check the following help documentation for more.
Column Types

Thanks,
Shinu.
0
Chetan
Top achievements
Rank 1
answered on 04 Apr 2013, 11:32 AM
Actually I have two columns, FormattedPhone and Phone. FormattedPhone has phone like (123)123-1234 and Phone has value like 1231231234. I have boundcolumn which has data coming from  FormattedPhone column. Also I have added filter for this column. When I search the record like 1234, it should return this phone. Is there any way so that I can change search column name to Phone from FormattedPhone. 

Thank you

0
Eyup
Telerik team
answered on 08 Apr 2013, 10:10 AM
Hello Chetan,

I am afraid it is difficult to figure out your exact requirement. Can you please elaborate on your specific scenario and provide us some screenshots demonstrating the desired behavior?

Looking forward to your reply.

Greetings,
Eyup
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
Chetan
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Chetan
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Eyup
Telerik team
Share this question
or