How to show serial number or line number in Ng grid?
2 answers
I made a planker that uses the ng-grid row.rowIndex property to show the row number in the first column: http://plnkr.co/edit/zLUinDSNUS8B1IrhzYhA?p=preview
$scope.gridOptions = {
data: 'myData',
columnDefs: [
{field: '', displayName: 'Row Number', cellTemplate: '<div class="ngCellText ng-scope col1 colt1" ng-class="col.colIndex()"><span ng-cell-text="">{{row.rowIndex + 1}}</span></div>'},
{field: 'name', displayName: 'Name'},
{field:'age', displayName:'Age'}]
};
+2
source to share
Using the {{rowRenderIndex + 1}} property , we can easily show the serial number in the ng-grid UI.
colDef = [{
name: 'ID',
field: '',
displayName: 'Id',
cellTemplate: '<span>{{rowRenderIndex+1}}</span>',
width: '10%'
}, {
field: 'data1',
displayName: 'Data1',
width: '40%'
},, {
field: 'data2',
displayName: 'Data2',
width: '40%'
}]
+1
source to share