在handsontable中未触发自定义单元格渲染器操作

编程入门 行业动态 更新时间:2024-10-27 08:39:01
本文介绍了在handsontable中未触发自定义单元格渲染器操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的表格html看起来像:

My table html looks like:

<hot-table settings="settings" row-headers="rowHeaders" min-spare-rows="minSpareRows" datarows="myData" columns="columns" > </hot-table>

我的选择:

$scope.columns = [ ... { data:'name', readOnly:true, renderer:$scope.myRenderer } ];

我的渲染器:

$scope.myRenderer = function(hotInstance, td, row, col, prop, value, cellProperties) { var metaId = hotInstance.getDataAtRowProp(row, 'metaId'); var specificationCode = hotInstance.getDataAtRowProp(row, 'specificationCode'); if(value && specificationCode) { td.innerHTML = '<a ng-click=\"openSpecification('+metaId+','+prop+','+specificationCode+')\">'+value+'</a>'; console.log(td.innerHTML); } };

单元格已正确呈现,但未触发ng-click .我什至只尝试了a href,但链接也无法正常工作.看起来我必须像stopPropagation或preventDefault那样做东西,但是我应该在哪里以及如何做呢?

Cell rendered properly but ng-click not triggered. I even tried just a href but link also not working. Looks like I have to make someting like stopPropagation or preventDefault but where and how should I do that?

推荐答案

这可能为时已晚,对您没有太大用处,但是您需要$compile $scope上的HTML,以便绑定到元素的指令.这样的事情应该可以解决问题:

This is probably too late to be of much use to you, but you'll need to $compile the HTML on your $scope in order for the directives to bind to the element. Something like this should do the trick:

$scope.myRenderer = function(hotInstance, td, row, col, prop, value, cellProperties) { var metaId = hotInstance.getDataAtRowProp(row, 'metaId'); var specificationCode = hotInstance.getDataAtRowProp(row, 'specificationCode'); var value = '<a ng-click=\"openSpecification('+metaId+','+prop+','+specificationCode+')\">'+value+'</a>'; var el = $compile(value)($scope); if (!(td != null ? td.firstChild : void 0)) { td.appendChild(el[0]); } return td; };

更多推荐

在handsontable中未触发自定义单元格渲染器操作

本文发布于:2023-11-23 02:06:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619701.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   单元格   中未   操作   渲染器

发布评论

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

>www.elefans.com

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