简体   繁体   中英

How to determine the row index in ng-grid for tool tip display

I am using a ng-grid on my cshtml page, its gridoption code in controller is as:

    $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
        }
    ]
};

I want to show a tool-tip in the second columns for each row where i need to fetch the row index on which mouse currently hovers and show: Row Number:1,2,3,4.. and so on

How can I achieve this.Please help

Thanks

I think it's not row.index but row.rowIndex so you should change it with:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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