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

Duplicate Filds in Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

126197 Sep 29,2016 07:56 PM UTC Oct 3,2016 01:48 PM UTC ASP.NET MVC 3
loading
Tags: Grid
Guilherme de Alvarenga
Asked On September 29, 2016 07:56 PM UTC

Good afternoon

I'm using a grid with editing and must ensure that the column with the name of theperson does not allow duplicate names.

If the user attempts to put duplicate name, should be shown a message that this is not allowed

How can I do that?

Prasanna Kumar Viswanathan [Syncfusion]
Replied On September 30, 2016 06:12 AM UTC

Hi Guilherme, 

Thanks for contacting Syncfusion support. 

We have already discussed about this requirement in the below knowledgebase documentation. 


Refer the above documentation and still if you face any issue, please get back to us.  
Regards, 
Prasanna Kumar N.S.V 


Guilherme de Alvarenga
Replied On September 30, 2016 12:23 PM UTC

Good day, I had tried to use this example, but I couldn't make it work.

This morning, I decided the issue as follows:

 col
                                        .Field(c => c.Description)
                                        .ValidationRules(v => v                                            
                                            .AddRule("minhaValidaçãoObrigatório", 0)
                                            .AddRule("minhaValidaçãoDeMaior50", 50)                                            
                                            .AddRule("messages", "{required:'" + Resource.ExpenseTypesListViewModel_DescriptionValidation + "'}")
                                        )
                                        .IsIdentity(true)
                                        .Priority(1)
                                        .Add();

------------------------------------------------

function begin(args) {
            if (args.requestType == "save") {
                $("#Editing").ejWaitingPopup("show");
               
                var findDuplicate = false;
                var Description = this.model.columns[1].field;
                for (var i = 0; i < args.model.currentViewData.length; i++) {
                    if (args.model.currentViewData[i].Description == args.data[Description]) {                        
                        args.cancel = true;                        
                        $("#DuplicateFieldDescriptionDialog").ejDialog("open");
                        $("#" + this._id + "_dialogEdit").ejDialog("close");                        
                        findDuplicate = true;
                        break;
                    }
                }                
                if (findDuplicate) {
                    return;                    
                } else {
                    var addToGrid = {};                    
                    addToGrid.Description = this.model.columns[1].field;                    
                    addToGrid.CreatorRE = this.model.columns[6].field;                    

                    var dateTimeNow = moment(moment()).format('DD/MM/YYYY HH:mm:ss');                 
                    args.data[addToGrid.CreatorRE] = loggedUserRE;
                }
            } 
        }


Prasanna Kumar Viswanathan [Syncfusion]
Replied On October 3, 2016 01:48 PM UTC

Hi Guilherme, 
  
We checked with your code example in our sample and the alert message has been displayed when we try to save the duplicate name. 
  
Find the code example and sample: 
  
  
@(Html.EJ().Grid<object>("FlatGrid") 
       .Datasource((IEnumerable<object>)ViewBag.datasource) 
       .AllowSorting() 
       .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
       ----------------------------- 
      .Columns(col => 
        { 
            --------------------------- 
       }) 
  
        .ClientSideEvents(eve => eve.ActionBegin("begin")) 
    ) 
  
<script> 
    function begin(args) { 
        if (args.requestType == "save") { 
            $("#FlatGrid").ejWaitingPopup("show"); 
                
            var findDuplicate = false; 
            var Description = this.model.columns[1].field; 
            for (var i = 0; i < args.model.currentViewData.length; i++) { 
                if (args.model.currentViewData[i].CustomerID == args.data[Description]) {                         
                    args.cancel = true;                         
                    alert("Not working"); 
                    findDuplicate = true; 
                    break; 
                } 
            }                 
            if (findDuplicate) { 
                return;                     
            }  
        }  
    } 
</script> 
  
  
  
To find the root cause of the issue we need the following details. 
  
1.  Do you face any script error in the console? If Yes, Share the stackrace of an issue. 
  
2. In the actionBegin event you have shown the waiting popup. So, do you need to hide the waiting-pop up after alert message is shown? 
  
3. Share the screenshot of an issue. 
  
4. If possible, replicate the issue in the attached sample. 
  
Regards, 
Prasanna Kumar N.S.V 
  
 


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

;