How do we show mask for inline editable grid column ?

1 Answer 268 Views
Grid
Teja
Top achievements
Rank 1
Teja asked on 23 Sep 2022, 11:59 AM

Hi All,

How do we show mask for phone number in editable grid? below is the my editable grid and i want show the mask for the phone column.

Thanks!

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Aleksandar
Telerik team
answered on 28 Sep 2022, 06:15 AM

Hello Teja,

To use an editor other than the default you can add a custom editor. Add an EditorTemplate containing a MaskedTextBox to the ~\Views\Shared\EditorTemplates folder and indicate the Grid should use it for the model property that should be a phone number. For example:

Model:

public class OrderViewModel
{
     public string Phone { get; set; }
...
}

 

Phone.cshtml:

@model string

@(Html.Kendo().MaskedTextBoxFor(m=>m)
    .Mask("(999) 000-0000")
)

 

Column definition:

@(Html.Kendo().Grid <OrderViewModel>()
                            .Name("grid")
                            .Columns(columns =>
                            {
                              ...
                                 columns.Bound(p => p.Phone).EditorTemplateName("Phone");
                                 columns.Command(c=>c.Edit());
                            })
..
)

 

I hope this helps.

Regards,
Aleksandar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Teja
Top achievements
Rank 1
Answers by
Aleksandar
Telerik team
Share this question
or