回调单元格点击在ui-grid

Callback on cell click in ui-grid

本文关键字:ui-grid 单元格 回调      更新时间:2023-09-26

我想有一个回调函数,每次点击单元格时触发。因此,我使用了以下回调:

gridAPI.cellNav.on.navigate($scope, function (newRowCol, oldRowCol)

但问题是,当同一单元格第二次被点击时,我不能触发该函数。为了触发此操作,应该选择不同的单元格。因此,only-first-click-on-cell是这样的

是否有任何回调,我可以在每次点击?

不,目前没有任何回调cellClick,据我所见

我能写的最好的技巧:

$scope.cellClicked = function (row, col){
 // do with that row and col what you want
}

每列单元格模板:

cellTemplate: '<div>
   <div ng-click="grid.appScope.cellClicked(row,col)" class="ui-grid-cell-contents" title="TOOLTIP">{{COL_FIELD CUSTOM_FILTERS}}</div>
      </div>',

不要用这个,最好使用:

rowTemplate: `
    <div
        ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid"
        ui-grid-one-bind-id-grid="rowRenderIndex + '-' + col.uid + '-cell'"
        class="ui-grid-cell"
        ng-click="grid.appScope.$ctrl.yourFunction(row)"
        ng-class="{ 'ui-grid-row-header-cell': col.isRowHeader }"
        role="{{col.isRowHeader ? 'rowheader' : 'gridcell'}}"
        ui-grid-cell>
    </div>`,