We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

I want to check duplicate record in grid

Technology must be in 

Angularjs and mvc

I want to insert only unique record in grid 
if I will enter non-unique record in grid 
I should show me an error.

like grid allowing only unique record 

Thank you waiting for you quick reply

1 Reply

RU Ragavee U S Syncfusion Team August 24, 2015 10:54 AM UTC

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());


                          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");






Please get back to us if you need any further assistance.

Ragavee U S

Live Chat Icon For mobile
Up arrow icon