单击时 ng

编程入门 行业动态 更新时间:2024-10-28 01:24:58
本文介绍了单击时 ng-grid/ui-grid celltemplate 会导致选择行.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

当我将 celltemplate 用于 ahref 链接时,一旦单击该链接,该行就会突出显示,因为我启用了 RowSelection...但我不希望该行在单击该链接时突出​​显示...链接.

When I use celltemplate for ahref link, once the link is clicked the row highlights because i have RowSelection enabled...but i dont want the row to highlight when the link is clicked..only if the row is clicked anywhere but the link.

同样在我下面的示例图片中,如何删除小箭头以便该列不能显示任何菜单项?

Also in my below example picture, how do I remove the little arrow so no Menuitems can be displayed for that column?

代码:

$scope.gridOptions = { 
    showFooter: true,
    enableFiltering: true,
    enableRowSelection: true,
    enableRowHeaderSelection: false,
    enableSelectAll: true,
    multiSelect: true,
    enableColumnResizing: true,
    columnDefs: [
    { field:'date', displayName: 'Date', width: 200, aggregationType: uiGridConstants.aggregationTypes.count  },
    { field:'notes', displayName: 'Notes', width: 65, enableFiltering: false, enableSorting: false, enableHiding: false, cellTemplate:'<a href="#" ng-click="getExternalScopes().showMe(row.entity[col.field])">View</a>' }
    ],
    data: data
}

图片:

推荐答案

这是 ui-grid(不再是 ng-grid!)的可能答案.

Here is a possible answer to ui-grid (which is not ng-grid anymore!).

不选择行的按钮的单元格模板是:

The cell template for a button that does not select the row is:

cellTemplate: '<button class="btn primary" ng-click="$event.stopPropagation();getExternalScopes().showMe(row)">Click Me</button>'

注意 ng-click 指令中的 $event.stopPropagation().这会阻碍点击到达rowTemplate的底层功能.(另请注意,除了使用 externalScopes 之外,我还没有找到将点击事件传递给控制器​​的另一种方法.我确定有更好的方法,但 ui-grid 仍然是测试版,我对它也很陌生)

Note the $event.stopPropagation() in the ng-click directive. This will hinder the click to reach the underlying functions of the rowTemplate. (Note also that I didn't found another way to pass a click event to the controller than by using externalScopes. I'm sure there is a better way but ui-grid is still beta and I'm also pretty new to it)

问题的第二部分:使用这个 headCellTemplate

Second part of your question: Use this headCellTemplate

var headCelltpl = '<div ng-class="{ \'sortable\': sortable }">' +
  '<div class="ui-grid-vertical-bar">&nbsp;</div>' +
  '<div class="ui-grid-cell-contents" col-index="renderIndex">' +
  '{{ col.displayName CUSTOM_FILTERS }}' +
  '</div>' +
  '</div>';

并将其添加到 columnDefs 中的相应列.

and add it to the respective columns in your columnDefs.

headerCellTemplate: headCelltpl

这是一个 Plunker,包含所有内容.

Here is a Plunker with everything included.

请不要告诉我你的意思是 ng-grid:-)

Please don't tell me you meant ng-grid:-)

这篇关于单击时 ng-grid/ui-grid celltemplate 会导致选择行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-21 05:39:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/998255.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   ng

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!