I have a ui-grid, based on mouse hover of user on a particular row, i need to show the button in a cell of that particular row. I tried with row template, in which i will call a method using 'grid.appScope,functionname()'. But its not working. Below us my code. 1.GridOptions:
$scope.gridOptions = {
headerTemplate: '/SourceHtml/Templates/HomeHeaderTemplate.html',
rowTemplate: rowTemplate(),
data: 'glues',
enableRowSelection: false,
enableCellEditOnFocus: true,
columnDefs:
[{ field: 'Name', displayName: 'Name', enableCellEdit: false },
{ field: 'Brand', displayName: 'Brand', enableCellEditOnFocus: true },
{ field: 'Quarter', displayName: 'Quarter', enableCellEditOnFocus: true },
{ field: 'Modified', displayName: 'Modified', enableCellEditOnFocus: true },
{ name: 'report', displayName: 'report', cellTemplate: '<button id="editBtn" type="button" class="btn-primary"><span class="glyphicon glyphicon-calendar"><span>Reports</span></span></button> ' },
{ name: 'edit', displayName: 'Edit', cellTemplate: '<button id="editBtnDdl" type="button" class="btn-primary"><span class="glyphicon glyphicon-cog"><span>Edit</span></span></button> ' }]
};
2.GridData:
$scope.glues = [{ Name: 'Bob', Brand: 'CEO', Quarter: '2015 Q1', Modified: 'Alexander' },
{ Name: 'Bob', Brand: 'CEO', Quarter: '2015 Q1', Modified: 'Alexander' }];
3.RowTemplate:
function rowTemplate() {
return $timeout(function () {
alert("hi");
return '<div ng-click="grid.appScope.fnOne(row)" ng-mouseover="grid.appScope.fnOne(row)" ng-repeat="col in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ui-grid-cell></div>';
}, 6000);
}
4.Method called from rowTemplate:
$scope.fnOne = function (entity) {
alert(row);
};
My plan is to call the fnOne() method from rowTemplate and from there to use ng-class="{hideByDefault:!inputs}", where hideByDefault display will be none and to set inputs to true in fnOne method. But fnOne method is not getting called.
Please suggest any ideas. Any other type of implementing also welcomed.