Created
April 8, 2017 04:36
-
-
Save A2H111/b84a16607cfe32454f52c7e66c131972 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Class to hold the customer data | |
$scope.Customer = { | |
customerID: '', | |
companyName: '', | |
contactName: '', | |
contactTitle: '' | |
}; | |
//Function to save the data | |
//Here we pass the row object as parmater, we use this row object to identify the edited row | |
$scope.saveRow = function (row) { | |
//get the index of selected row | |
var index = $scope.gridOptions.data.indexOf(row); | |
//Remove the edit mode when user click on Save button | |
$scope.gridOptions.data[index].editrow = false; | |
//Assign the updated value to Customer object | |
$scope.Customer.customerID = row.CustomerID; | |
$scope.Customer.companyName = row.CompanyName; | |
$scope.Customer.contactName = row.ContactName; | |
$scope.Customer.contactTitle = row.ContactTitle; | |
//Call the function to save the data to database | |
CustomerService.SaveCustomer($scope).then(function (d) { | |
//Display Successfull message after save | |
$scope.alerts.push({ | |
msg: 'Data saved successfully', | |
type: 'success' | |
}); | |
}, function (d) { | |
//Display Error message if any error occurs | |
$scope.alerts.push({ | |
msg: d.data, | |
type: 'danger' | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment