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

GridMaskedColumn + CurrentFilterFunction + AutoPostBackOnFilter = No filtering on ENTER

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kent Williams
Top achievements
Rank 1
Kent Williams asked on 16 Dec 2008, 06:25 PM
I have a grid with 4 filterable columns. We want the endusers to be able to press ENTER and have it, by default, select "EqualTo" and filter the grid. This functionality is working on 3 of the 4 columns, by adding:

CurrentFilterFunction

 

="EqualTo" AutoPostBackOnFilter="true"

 


However, the 4th column is a GridMaskedColumn, and acts odd. I'm using Q3 2008 .NET3.5 version of the rad controls. When the user hits enter from the masked column, you can breifly see a menu popup at the location of the mouse cursor. If I disable AutoPostBackOnFilter I can then figure out that the menu is actually from the 1st column, not the 4th (Masked) column. Either way, when the page reloads it shows everything in its previous state, completely ignoring what is in the GridMaskedColumn filter (whats even more weird is it persists the text in the box -- but dosn't filter on it).

Here's the code, any help would be greatly appriciated:

 

<telerik:GridMaskedColumn UniqueName="SSN" HeaderText="SSN" DataField="SSN" CurrentFilterFunction="EqualTo"

 

 

FilterControlWidth="80px" Mask="###-##-####">

 

<

 

ItemStyle CssClass="certcolpadding"></ItemStyle>

 

 

</telerik:GridMaskedColumn>

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 19 Dec 2008, 04:13 PM
Hello Kent Williams,

Unfortunately the problem which you described is a bug - I logged it in our bug tracking system to be address for the future versions of the product.

We can suggest you a workaround for this issue. It can be resolved if you subscribe to the OnKeyPressed event of the RadMaskedTextBox control inside the column and prevent the event bubbling. First you have to wire the OnItemCreated event of the grid and there find filter item. Then you just have to find the column which contains the RadMaskedTextBox filter and wire its ClientSide.OnKeyPressed event.

Here is a code snippet:
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridFilteringItem)  
        { 
            GridFilteringItem filterItem = ((GridFilteringItem)e.Item); 
            RadMaskedTextBox maskedTextBox = (RadMaskedTextBox)filterItem["ShipPostalCode"].Controls[0]; 
            maskedTextBox.ClientEvents.OnKeyPress = "KeyPressed"
            RadGrid1.MasterTableView.Columns.FindByUniqueName("ShipPostalCode").CurrentFilterFunction = GridKnownFunction.EqualTo; 
        } 
    } 

Then just implement the function which will handle the raised event. Review this code for more details:
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
        <script type="text/javascript"
            function KeyPressed(maskedTextBox, e) { 
                if (e.get_domEvent().rawEvent.keyCode == 13) { 
                    e.get_domEvent().preventDefault() 
                    e.get_domEvent().stopPropagation() 
                }  
        </script> 
    </telerik:RadScriptBlock> 


Kind regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Kent Williams
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or