只允许某些行是在NG-网编辑 [英] Only allow some rows to be editable in ng-grid
本文介绍了只允许某些行是在NG-网编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个NG-网格,我想只允许某些行进行编辑。这似乎NG-电网是一个全有或全无编辑网格,我失去的东西还是有解决方法吗?
I have an ng-grid that I would like to allow only certain rows to be editable. It seems ng-grid is an all or nothing editable grid, am I missing something or is there a workaround?
推荐答案
我想出了解决办法是在NG-编辑细胞,如果指令的额外条件,以取代在$ templateCache的cellEditTemplate。例如,我们要排0可编辑和行1为只读:
The workaround I came up with is to replace the cellEditTemplate in the $templateCache with an extra condition on the ng-edit-cell-if directive. For example, we want row 0 to be editable and row 1 to be read only:
$templateCache.put("cellEditTemplate.html",
"<div ng-cell-has-focus ng-dblclick=\"editCell()\">" +
" <div ng-edit-cell-if=\"!isFocused || row.rowIndex == 1\"> " +
" DISPLAY_CELL_TEMPLATE" +
" </div>" +
" <div ng-edit-cell-if=\"isFocused && row.rowIndex == 0\">" +
" EDITABLE_CELL_TEMPLATE" +
" </div>" +
"</div>"
);
这篇关于只允许某些行是在NG-网编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文