javascript - 更改 Angular ui.grid 中的 MenuItem 图标

标签 javascript angularjs grid ng-grid angular-ui-grid

如何在 Angular ui.grid 中切换 customizing_column_menu 图标,如下所示

enter image description here

enter image description here

最佳答案

我没有找到任何动态更改菜单项的最佳解决方案,这是我为解决方法所做的

代码

$scope.gridOptions = {
  rowHeight: 75,
  columnDefs: [{
    field: 'name',
    enableColumnMenu: false
  }, {
    field: 'gender',
    enableHiding: false,
    suppressRemoveSort: true,
    sort: {
      direction: uiGridConstants.ASC
    }
  }, {
    field: 'All Details',
    cellTemplate: '<p ng-show="grid.appScope.company"><label><b>Company:</b></label><span>{{row.entity.company}}</span></p><p ng-show="grid.appScope.email"><label><b>email:</b></label><span>{{row.entity.email}}</span></p>',
    menuItems: [{
      title: 'Company',
      icon: 'ui-grid-icon-ok',
      action: function() {
        $scope.company = $scope.company ? false : true;
      },
      context: $scope,
      shown: function() {
        return this.context.company;
      }
    },{
      title: 'Company',
      icon: 'ui-grid-icon-cancel',
      action: function() {
        $scope.company = $scope.company ? false : true;
      },
      context: $scope,
      shown: function() {
        return !this.context.company;
      }
    }, {
      title: 'Email',
      icon: 'ui-grid-icon-ok',
      action: function() {
        $scope.email = $scope.email ? false : true;
      },
      context: $scope,
      shown: function() {
        return this.context.email;
      }
    }, {
      title: 'Email',
      icon: 'ui-grid-icon-cancel',
      action: function() {
        $scope.email = $scope.email ? false : true;
      },
      context: $scope,
      shown: function() {
        return !this.context.email;
      }
    }]
  }]
};

Working Plunkr

关于javascript - 更改 Angular ui.grid 中的 MenuItem 图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29643310/

相关文章:

javascript - 根据经验计算等级

javascript - fadeTo 在 ie10 中不起作用

javascript - 如何在下拉列表中传递所选值并附加到 site_url 中?

Android material 对齐字体基线到 4dp 网格

python - 使用 networkx 绘制图形时显示背景网格(也称为单元格)

javascript - 在不重新加载页面的情况下重置 innerHTML

javascript - 当最初在范围内设置值时,日期选择器弹出格式不起作用

javascript - 将 Bootstrap 行与其旁边的标签对齐

javascript - 在 ng-repeat 中使用 ng-if 和 ng-switch 失败

asp.net-mvc - Kendo UI ASP MVC 无法获取网格选定行值