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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

I want to check duplicate record in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

119999 Aug 21,2015 01:12 PM UTC Aug 24,2015 10:54 AM UTC JavaScript 1
loading
Tags: ejGrid
Bharat Buddhadev
Asked On August 21, 2015 01:12 PM UTC

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



Ragavee U S [Syncfusion]
Replied On 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());

                      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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;