insert ng-click event into ng-grid

风格不统一 提交于 2019-11-28 23:51:49

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

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

$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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!