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

[Solved] Input Masking By Column

3 Answers 152 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Philip
Top achievements
Rank 1
Philip asked on 11 Jul 2009, 07:31 PM
Hello,

I have a question today in regards to creating a mask for input for cells in a grid dependent upon column. For example, for a cell edited in the "Name" column would allow anything, but only 50 characters, but a cell in the "Zip Code" column allowing only 5 sequential numbers. This could, theoretically, be done through management of CellEditEnded events, but I'd prefer to mask the entered text on the fly, not after the use has already entered the text.

I am aware of things such a masked text boxes, but have no experience with them. Is there a way to implement this feature into Telerik's grids, whether by an already implemented feature, a template, or some other coded method?

Thanks to everyone for their time,

Philip Coffey

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 13 Jul 2009, 05:39 AM
Hi Philip,

You can put desired MaskedTextBox with desired settings directly in the column CellEditTemplate. Please check this demo:
http://demos.telerik.com/silverlight/#GridView/CellEditTemplate

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Philip
Top achievements
Rank 1
answered on 13 Jul 2009, 04:13 PM
Thank you, that has provided the majority of what I need.

If it would be possible, however, could you give an example of how to create and set a column's CellEditTemplate programatically? The requirements for our project require a large volume of dynamically created content, which has proven easier to code for us in c# than .xaml.

Thanks again,
Philip
0
Pavel Pavlov
Telerik team
answered on 16 Jul 2009, 04:10 PM
Hi Philip,

Of course ,

Here is some sample code :

private void SetStyleToColumns()  
        {  
            Style customColumnStyle = this.LayoutRoot.Resources["CustomCellEditTemplate"as Style;  
            foreach (var column in RadGridView1.Columns)  
            {  
                column.CellEditTemplate = customColumnStyle;  
            }  
        } 

This code assumes that the style is defined in the resources of the LayoutRoot element ( typically a Grid).

You may call this method immediately  after set the ItemsSource property of the RadGridView , or after you have set the columns property.

Greetings,

Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Philip
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Philip
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or