Button click does not work in Celltemplate angular grid

旧时模样 提交于 2019-12-02 03:16:07

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' },

        ]

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

it is working for me now!

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>' }

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