我在角js中使用wijgrid组件,我遇到了无法在it.in wijgrid组件上执行单击事件的问题,请查找html代码。
<wij-grid id = "dataGrid" allow-sorting="true" data="data" columns-autogeneration-mode="none" allow-paging="true" >
<columns>
<column data-key="name" header-text="Name"></column>
<column data-key="address" header-text="Address" ></column>
<column data-key="submit" header-text="Submit"></column>
</columns>
</wij-grid> 还有我的js代码
$http.get(url,data).success(
loadData);
function loadData(responseData) {
if (responseData != null) {
var data = responseData;
for (index = 0; index < data.length; index++) {
data[index].address = data[index].addressLineOne+","+data[index].addressLineTwo;
$SubmitBtn = "<a href='javascript:void(0);ng-click='submitCode("+data[index].reviewId+",true)'>Approve</a>"; data[index].submit=$ASubmitBtn;
}
$scope.data = data;
$("#content").wijtabs();
}
}
$scope.submitCode= function(id, status) {
alert(id+" "+status)
} 在这里,提交代码函数没有调用,而且在查看源代码时,函数显示的是id和状态。这意味着它没有编译在wijgrid模块中,请帮助我提供解决方案。我试图编译代码$compile($sumitBtn)($scope),但它不起作用,请给我建议s0lution
发布于 2013-11-28 06:23:13
我得到了使用单元格格式化方法的解决方案,我根据我的要求修改了代码。
$scope.formatter = function(args) {
if(args.row.dataRowIndex < 0 )
return false;
args.$container
.html($compile(
args.formattedValue)
($scope));
return true;
} 发布于 2013-11-24 23:23:05
Wijmo意识到了这个问题,并说这是一个已知的bug。我用的解决办法是:
$scope.cellStyleFormatter = function(args) {
if ((args.row.type & wijmo.grid.rowType.data) && (args.row.state & wijmo.grid.renderState.rendering)) {
var content = args.$cell[0].innerHTML;
//Here I have button html already in my grid data, using
//'my-link-class' css
if(content.indexOf("my-link-class") > -1) {
var scope = angular.element("#grid-container").scope();
args.$cell
.empty()
.append($(content).click(function () {
scope.myControllerClickHandler();
})
);
}
return true;
}
};我宣布我的网格如下:
<wij-grid data="template.model.content" allow-editing="false" cellStyleFormatter="cellStyleFormatter">
<columns>
<column dataKey="col_0" ></column>
</columns>
</wij-grid>我使用上面的cellStyleFormatter,因为我可以将它全局应用于整个网格。如果提前知道该列,可以使用cellFormatter (我的应用程序有可变的列数,所以这对我来说不是一个选项)。如果使用args.container,您将引用cellFormatter而不是args.$cell。
下面链接到wijmo的解释:http://wijmo.com/topic/wig-grid-with-angularjs-how-to-handle-click-on-a-link-in-a-cell/
https://stackoverflow.com/questions/20139329
复制相似问题