我对棱角和智能表(http://ngmodules.org/modules/Smart-Table)非常陌生,我正在尝试为表行添加删除功能。有一个内置函数(removeDataRow),但与它的近亲updateDataRow不同,我还没有弄清楚如何触发它。以下是迄今为止的相关代码:
deleteAction.html:
<button custom ng-click="doAction()"
class="btn btn-xs btn-primary">
Delete
</button>表列定义:
$scope.columnCollectionDispo = [
{label: 'ID', map: 'dispositionId', isEditable: false},
{label: 'Name', map: 'name', isEditable: true},
{label: 'Code', map: 'code', isEditable: true},
{label: 'Description', map: 'description', isEditable: true},
{label: 'Sort Index', map: 'sortIndex', isEditable: true, type: 'number'},
{label: 'Status', map: 'status'},
{label:'actions', cellTemplateUrl:'../views/admin/deleteAction.html'}
];表Global Config:
$scope.globalConfig = {
isPaginationEnabled: true,
itemsByPage: 5,
maxSize: 10,
selectionMode: 'single',
doAction: function(){
$scope.$emit('deleteAction');
}
};删除方法:
$scope.$on('deleteAction',function(){
alert("Delete List"); //just to see if I am reaching this code
});表显示:
<smart-table class="table table-striped" table-title="DispoElements"
config="globalConfig" rows=dispoElements columns="columnCollectionDispo">
</smart-table>我可以显示删除按钮,并花费一些循环时间试图触发removeDataRow方法。如果没有做到这一点,我一直在试图找出如何将表元素id传回执行delete。我宁愿使用内置功能。有什么想法吗?蒂娅,泰德
发布于 2014-07-01 21:00:12
我想答案是你不能。我把智能桌换成了trNgGrid,它似乎运行得更好了。显示、编辑和删除工作正常。努力添加。到目前为止,add可以工作,但我希望网格转到新添加的记录,并将其置于编辑模式中,但到目前为止还没有效果。仍然是一项正在进行的工作。
发布于 2014-07-16 05:41:23
由于使用的智能表指令将其作用域与父控制器隔离开来,因此不能直接访问父控制器中定义的函数。
要访问相同的属性,可以使用$parent属性
在deleteAction.html里试试这个,
<button ng-click="$parent.$parent.$parent.$parent.doDelete(dataRow)"
class="btn btn-xs btn-primary">
Delete
</button>表列定义,
$scope.columnCollectionDispo = [
{label: 'ID', map: 'dispositionId', isEditable: false},
{label: 'Name', map: 'name', isEditable: true},
{label: 'Code', map: 'code', isEditable: true},
{label: 'Description', map: 'description', isEditable: true},
{label: 'Sort Index', map: 'sortIndex', isEditable: true, type: 'number'},
{label: 'Status', map: 'status'},
{label:'actions', cellTemplateUrl:'../views/admin/deleteAction.html'}
];在你父母的控制器里,
$scope.doDelete=funcion(dataRow){
alert('inside doDelete');
//implement the code for delete action
}这是柱塞工作演示,
http://plnkr.co/edit/87yfJQEbBjzOlJoCZ3aq?p=preview
https://stackoverflow.com/questions/24388453
复制相似问题