1

I m trying to work with celltemplate. But click event did not work.

    $scope.format = function(val){
            return val.replace(/\//g, "");
        };

        var executionColumns = {
            data: [],
            enableSorting: true,
            paginationPageSizes: [25, 50, 75],
            paginationPageSize: 25,
            enableColumnMenu: true,
            enableFiltering: true,
            columnDefs: [

              { field: 'StartDate', cellTemplate: '<button ng-click="format (row.entity)">log</button>' },
              { field: 'Status' },

            ]

        };

So what should I do? What is the wrong?

Kle
  • 1,003
  • 2
  • 14
  • 24

3 Answers3

2

It works for me like the 2nd code

         columnDefs: [
          { field: 'StartDate', cellTemplate: '<button ng-click="format(grid.getCellVale(row.entity)   )">log</button>' },
          { field: 'Status' },

        ]

or move your format function to an externalscope defined as

 $scope.globalExternalScope = {
       format:function(entity){..........}
    }

and then use the template like

         columnDefs: [
          { field: 'StartDate', cellTemplate: '<button ng-click="getExternalScopes().format(grid.getCellVale(row.entity)   )">log</button>' },
          { field: 'Status' },

        ]
Divya MV
  • 2,021
  • 3
  • 31
  • 55
  • 1
    I read http://ui-grid.info/docs/#/tutorial/099_upgrading_from_2 and I ediğt my code like below and worked. Intersting: '' – Kle Feb 17 '15 at 07:17
0

Use <button ng-click="grid.appScope.format (row.entity)">log</button>

it is working for me now!

Santosh
  • 2,093
  • 1
  • 15
  • 21
0

In case you are using .component inside of which you render a ui-grid and your method is defined as: this.handleClick = function(){...}

It will be available to you in cellTemplate via cellTemplate: '<button ng-click="grid.appScope.$ctrl.handleClick()">log</button>' }

Shevchenko Viktor
  • 5,206
  • 2
  • 17
  • 26