app.controller('MainCtrl', ['$scope', function ($scope, i18nService) {
i18nService.setCurrentLang("zh-cn");
$scope.gridOptions = {
enableSorting: true,
//编辑完成后执行事件
onRegisterApi: function (gridApi) { $scope.gridApi = gridApi; $scope.gridApi.edit.on.afterCellEdit($scope, function (rowEntity) { //编辑离开事件 $http.post('/manage/api/dictionary/update', { "accountName": rowEntity.accountName, "userName": rowEntity.userName, "unitName": rowEntity.unitName, }) .success(function (data) { if (data.meta.success) { alert('修改成功'); } else { alert(data.meta.message); } }) .error(function () { toastr.warning("服务器出错,无法获取数据"); }); }); },
columnDefs: [
{field: 'accountName', displayName:'手机号', width: 200},
{field: 'userName', displayName:'用户名', width: 100},
{field: 'unitName', displayName:'单位', width: 300},
{
field: 'createTime', displayName: '注册时间', width: 200,
cellTemplate: ''
},
{
field: 'roleList', displayName: '类型', width: 200,
cellTemplate: '{{item.roleName}}'
},
{
field: 'accountId', displayName: '详细信息', width: 200,
cellTemplate: ' 查看详情'
}
]
}; $scope.gridOptions.data = [ { 'accountName':'15555555555', 'userName':'浮生若梦', 'unitName':'无', 'createTime':1506661676435, 'roleList':[{roleName:'前端','roleId':2},{roleName:'后端','roleId':3}], 'accountId':201 },
{ 'accountName':'15555555555', 'userName':'浮生若梦', 'unitName':'无', 'createTime':1506661676435, 'roleList':[{roleName:'前端','roleId':2},{roleName:'后端','roleId':3}], 'accountId':201 }
]
}]);
|