insert ng-click event into ng-grid

前端 未结 3 1592
暖寄归人
暖寄归人 2020-12-15 11:14

i want to do something that i don\'t know if it is possible

HTML


    
    

        
相关标签:
3条回答
  • 2020-12-15 11:53

    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

    0 讨论(0)
  • 2020-12-15 12:01

    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

    0 讨论(0)
  • 2020-12-15 12:17
    $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.

    0 讨论(0)
提交回复
热议问题