Hi Bharat,
We have analyzed your requirement to alert error message when duplicate data is inserted to grid.
Based on your requirement we have created a sample in webapi and angular js. The sample can be downloaded from the below location.
Sample Link:
http://www.syncfusion.com/downloads/support/forum/119999/ze/Sample-1759478651
In the
ActionBegin event of the grid, when the
requestType is “
save”, we have compared the inserted values with grid datasource. If the values are same, we have prevented the AJAX save request by defining
args.cancel as true and closed the dialog. Please refer the below code snippet.
<script type="text/javascript">
angular.module('Ctrl', ['ejangular'])
.controller('GridCtrl', function ($scope) {
. . . .
$scope.actionBegin = function (args) {
if (args.requestType == "beginEdit" || args.requestType == "add") {
promise = (this.model.dataSource()).executeQuery(new ej.Query());
promise.done(function(e){
data = e.result;// get the dataSOurce of the grid
});
}
if (args.requestType == "save") {
for (var i = 0; i < data.length; i++)
//check if the entered data is already present in the grid
if (args.data.CustomerID == data[i].CustomerID || args.data.EmployeeID == data[i].EmployeeID || args.data.ShipCountry == data[i].ShipCountry) {
args.cancel = true;
alert("Please enter only unique values");
$("#" + this._id + "_dialogEdit").ejDialog("close");
break;
}
}
}
});
</script>
|
Please get back to us if you need any further assistance.
Regards
Ragavee U S