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

Filter Item Max Length

2 Answers 286 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 01 Apr 2010, 11:57 PM
Is it possible to set the maxlength on the filter item?

Ironically, the filter item seems to inherit most of the column properties, data type for example, but it ignores the maxlength property. I have a field that is an int16, but I want to limit the user from typing in more than four numbers.

Also, I don't want to show the comma if the value is greater than 999.

I would prefer not to have to go to the trouble of creating FilterTemplates if possible. It is a shame that there don't seem to be more filter properties in the grid column.

2 Answers, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 02 Apr 2010, 09:02 PM
Here is the solution:
        protected void RadGrid_ItemCreated(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridFilteringItem)  
            {  
                TextBox txtClientAssetId = ((e.Item as GridFilteringItem)["ClientAssetId"].Controls[0] as TextBox);  
                if (txtClientAssetId != null)  
                {  
                    txtClientAssetId.MaxLength = 20;  
                }  
 
                TextBox txtAddress = ((e.Item as GridFilteringItem)["Address"].Controls[0] as TextBox);  
                if (txtAddress != null)  
                {  
                    txtAddress.MaxLength = 20;  
                }  
            }  
        }  
 
 

but I have to say, what a huge pain in the a##. I am not a fan of the radgrid filtering. I am going to revert their filters and just create my own. The implementation is a real drag.

Things that could make it much nicer:
1) A setting for max length on the filter control.
2) A global setting for filter menu items by data type. If I could go in and say I want the following menu items for all int32 filters, that would be awesome.
3)  An option to display a button to reset all filters
4) an option at the grid level to use a search button to start the search rather than an autopostback for each filter selection.

0
Yavor
Telerik team
answered on 07 Apr 2010, 07:25 AM
Hello Jim,

Indeed, this is one possible option to handle the desired setup.
Another option is to use a filter template, and define the look and feel of the filter menu for a given cell manually. This gives you the greatest flexibility, without having to write much code. Additional information on this option is available in the following example:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx

I hope it gets you started properly.

Best wishes,
Yavor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Jim
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or