i want to do something that i don\'t know if it is possible
The document on their github site is really old.
here is a link to the right page for this problem. http://ui-grid.info/docs/#/tutorial/305_appScope
yourCtrl.gridOptions = {
enableFiltering: true,
enableHiding : false,
enableSorting: true,
appScopeProvider : yourCtrl,
rowTemplate: '<div ng-click="grid.appScope.doSomething(row)" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" class="ui-grid-cell" ng-class="col.colIndex()" ui-grid-cell></div>',
};
yourCtrl.doSomething = function(row) {
alert("lala");
}
yes, somehow
ng-click="grid.appScope.doSomething"
won't work
These definitions work for me:
$scope.gridOptions = {
data: 'myData',
columnDefs: [{
field: 'name',
displayName: 'Name',
cellTemplate: '<div ng-click="foo()" ng-bind="row.getProperty(col.field)"></div>'
}, {
field: 'age',
displayName: 'Age',
cellTemplate: '<div ng-click="foo()" ng-bind="row.getProperty(col.field)"></div>'
}
]
};
See your forked Plunker here
$scope.ShowDetails=function(_obj)
{
alert('Hi! ' + _obj);
}
$scope.gridOptions = {
columnDefs: [
{ name: 'Search', field: 'Col1', cellTemplate: '<div ng-click="grid.appScope.ShowDetails(row)"><img src="/images/search.png" /></div>' },
{ name: 'Col2', displayName: 'Col2' },
]};
Here the example to attach an event to a ui grid cell.