简体   繁体   English

掩盖剑道网格中的指定列

[英]Masking a specified column in kendo grid

Here is my grid initialization: 这是我的网格初始化:

@(Html.Kendo().Grid<UT.CRM.ViewModels.DemoUserListViewModel> ()
    .Name("demoUsers")
    .Columns(columns =>
    {
        columns.Bound(c => c.CustomerName).Title("Ad Soyad").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
        columns.Bound(c => c.Login).Title("Hesap").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
        columns.Bound(c => c.DayCount).Title("Toplam Gün").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
        columns.Bound(c => c.TradeCount).Title("Toplam İşlem").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
        columns.Bound(c => c.RegistrationDate).Title("Kayıt").Format("{0:dd.MM.yyyy}").Filterable(ftb => ftb.Cell(cell => cell.Operator("eq")));
        columns.Bound(c => c.Email).Title("E-Posta").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
        columns.Bound(c => c.Phone).Title("Phone").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
    })
    .HtmlAttributes(new { style = "height: 690px;" })
    .Scrollable()
    .Sortable()
    .Resizable(resize => resize.Columns(true))
    .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("GetDemoUsersReport", "Reports"))
    )
)

As you see I have a column having phone values. 如您所见,我有一列包含电话值。 I want these phone values to be formatted as below: 我希望这些电话值的格式如下:

05356645879 -> ****664**** 05356645879-> **** 664 ****

Is it possible? 可能吗?

Thanks in advance, 提前致谢,

Try setting a ClientTemplate as below: 尝试如下设置ClientTemplate

columns.Bound(c => c.Phone).ClientTemplate(@"#: phone.replace(/^\\d{4}|\\d{4}$/g, \'****\') #").Title...

I could not test it with ASP.Net, but here is a demo in pure javascript. 我无法使用ASP.Net对其进行测试,但这纯JavaScript 演示 Any problems please let me know. 如有任何问题,请通知我。

UPDATE: I forgot to say that the best and safer way to achieve that is to do the same thing, but in your server side. 更新:我忘了说实现这一目标的最佳和更安全的方法是在您的服务器端执行相同的操作。 So the user cannot get the information in the raw request result. 因此,用户无法在原始请求结果中获取信息。 But if you think that isn't necessary, it is ok. 但是,如果您认为这没有必要,那就可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM