【问题标题】:How to determine the row index in ng-grid for tool tip display如何确定 ng-grid 中的行索引以进行工具提示显示
【发布时间】:2015-11-06 06:24:45
【问题描述】:

我在我的cshtml页面上使用了一个ng-grid,它在控制器中的gridoption代码如下:

    $scope.myGridOptions = {
    dataSource: myGridFiles,
    sortable: true,
    filterable: {
        extra: false
    },
    scrollable: true,
    dataBound: function () {
        window.scrollTo(0, 0);
        $pageData.isLoading = false;
    },
    columns: [
        {
            template: '<span class="icon-adjust center"><input type="checkbox" ng-click="selectFile(dataItem)" /></span>',
            width: 28
        },

       {
            template:  '<a class="js-mul-tooltip" title="Row Number:{{row.index+1}}"><i class="mul-icon-row"></i></a>',
            width: 28
        },

        {
            field: 'UploadedDate',
            title: $i18n.filerepo.dateUploaded,
            template: '<span class="center">#= kendo.toString(kendo.parseDate(UploadedDate, "yyyy-MM-dd"), "dd-MMM-yy") #</span>',
            width: '14%',
            filterable: false
        },
        {
            field: 'UploadedBy',
            title: $i18n.filerepo.uploadedBy,
            width: '11%',
            filterable: false
        },

        {
            field: 'Notes',
            title: $i18n.filerepo.notes,
            template: '<span class="text-overflow" ng-attr-title="{{dataItem.Notes}}" ng-bind="dataItem.Notes"></span>',
            width: '25%',
            filterable: false
        },
        {
            field: 'DocumentKey',
            title: $i18n.filerepo.uniqueidentifier,
            width: '14%',
            filterable: false
        }
    ]
};

我想在每行的第二列中显示一个工具提示,我需要在其中获取鼠标当前悬停的行索引并显示:行号:1,2,3,4.. 等等

我怎样才能做到这一点。请帮助

谢谢

【问题讨论】:

  • 你的代码有什么问题?没有显示前两列吗?
  • 在第二列中,我需要将工具提示显示为:行号 1(或 2 或 3..)。行号未出现:{ template: '',宽度:28 }跨度>

标签: javascript angularjs ng-grid


【解决方案1】:

我认为不是row.index,而是row.rowIndex,所以你应该用:

{
     template:  '<a class="js-mul-tooltip" title="Row Number:{{row.rowIndex+1}}"><i class="mul-icon-row"></i></a>',
     width: 28
},

【讨论】:

  • using: row.rowIndex 不会给出任何空白
猜你喜欢
  • 1970-01-01
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-16
  • 2014-12-24
  • 2021-12-21
  • 2019-01-11
相关资源
最近更新 更多