我对 Angular 和 Smart-Table ( http://ngmodules.org/modules/Smart-Table ) 很陌生,我正在尝试为表格行添加删除功能。有一个内置函数 (removeDataRow),但与附近的表亲 updateDataRow 不同,我无法弄清楚如何触发它。到目前为止,这是相关的代码:
删除操作.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'}
];
表全局配置:
$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>
我可以显示 Delete 按钮并花费一些周期时间来尝试触发 removeDataRow 方法。如果做不到这一点,我一直在试图弄清楚如何将表元素 id 传回以执行删除。我宁愿使用内置函数。有任何想法吗?TIA,泰德