【问题标题】:Display Custom Command Button Kendo UI Grid in MVC with Conditional Authorization Role在具有条件授权角色的 MVC 中显示自定义命令按钮 Kendo UI 网格
【发布时间】:2014-10-19 10:58:12
【问题描述】:

带有条件 Au 自定义命令按钮的 MVC 中的 Kendo UI 网格 如何根据授权有条件地显示销毁或自定义命令按钮

我想在 kendo MVC 网格中为拥有 Role="Admin" 的用户显示自定义命令 喜欢

@if (HttpContext.Current.User.Identity.IsAuthenticated)
{
   if (HttpContext.Current.User.IsInRole("Admin"))
   {    

在我的剑道网格中

@(Html.KendoGrid<Management.Models.Users.UserModel>("dgvUser", "PartialCustomUserModel", false)

.Columns(c => c.Command(cc =>
    {
    cc.Custom("delete").HtmlAttributes(new
   {

    @style = @"
                color : transparent;
                background-position: center center;
                background-image: url('../Content/themes/base/images/blue/imgEditUser.png');
                background-size: contain;
                background-repeat: no-repeat;
                height: 28px;
                cursor: pointer;"
}).Click("deleteUser");

我能做什么?

【问题讨论】:

    标签: asp.net-mvc conditional-statements authorization kendo-grid


    【解决方案1】:

    你可以使用下面的

    @(Html.Kendo()
          .Grid<YourModel>()
          .Name("Grid")
          .Columns(columns =>
          {
              columns.Command(command =>
              {
                  if (User.IsInRole("Admin"))
                  {
                      command.Custom("delete").Click("deleteUser");
                  }
              }).Title("Commands");
          }))
    

    或者很容易,而不是添加自定义按钮,只需添加销毁按钮

    希望对你有帮助

    【讨论】:

    • Tnx Dude... 很有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 1970-01-01
    • 2013-10-09
    • 1970-01-01
    相关资源
    最近更新 更多