NG-格如何显示在最后一排一列单元格/隐藏按钮 [英] ng-grid how to show/hide button in a column cell for last row

查看:256
本文介绍了NG-格如何显示在最后一排一列单元格/隐藏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NG-网格表和列DEFS都有一个单元模板,以显示图标之一。目前图标显示了所有行。

谁能帮我如何为NG-网格中的最后一行显示的图标。

我试着用 NG-秀='$最后,并没有工作。

  $ scope.reasonsGrid = {
         数据:'m​​yReasons',
        columnDefs:
            {场:添加,显示名:'',cellTemplate:addTemplate,enableCellEdit:假的,宽度:30},
          {场:'code',显示名:'原因',cellTemplate:dropdownTemplate,enableCellEdit:假}]
        };VAR addTemplate ='跨度类=glyphicon glyphicon加征NG点击=的addItem(row.rowIndex)NG秀=$最后一个/>';;


解决方案

试试这个code:

  VAR CTPL ='< D​​IV NG秀=row.rowIndex == myData.length-1级=ngCellText><按钮NG点击=的addItem(),>添加项目< /按钮>< / DIV>';  $ scope.gridOptions = {
    数据:myData的,
    enableRowSelection:假的,
    columnDefs:[{
      现场:'名',
      显示名:名称
    },{
      现场:'年龄',
      显示名:'年龄',
    },{
      显示名:'动作',
      cellTemplate:CTPL
    }]
  };  $ scope.addItem =功能(){
    $ scope.myData.push({名称:新,年龄:''});
  }

看它这里工作

I have a ng-grid table and one of the column Defs has a cell template to show icon. Currently icon shows up across all rows.

Can anyone help me how to display icon for the last row in ng-grid.

I tried using ng-show='$last' and didn't work.

$scope.reasonsGrid = { 
         data: 'myReasons',                    
        columnDefs: [
            {field: 'add', displayName:'', cellTemplate: addTemplate,enableCellEdit: false,width:30},
          {field: 'code', displayName: 'Reasons',cellTemplate: dropdownTemplate,enableCellEdit: false}]
        };

var addTemplate ='span class="glyphicon glyphicon-plus-sign" ng-click="addItem(row.rowIndex)" ng-show="$last"/>';;

解决方案

Try this code:

  var ctpl = '<div ng-show="row.rowIndex==myData.length-1" class="ngCellText"><button ng-click="addItem()"">Add Item</button></div>';

  $scope.gridOptions = {
    data: 'myData',
    enableRowSelection:false,
    columnDefs: [{
      field: 'name',
      displayName: 'Name'
    }, {
      field: 'age',
      displayName: 'Age',
    }, {
      displayName: 'Action',
      cellTemplate: ctpl
    }]
  };

  $scope.addItem=function(){
    $scope.myData.push({name:'new',age:''});
  }

See it working here

这篇关于NG-格如何显示在最后一排一列单元格/隐藏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆