1. #1
    Sencha Premium Member
    Join Date
    Oct 2009
    Location
    Aylesbury, Bucks, UK
    Posts
    37
    Vote Rating
    5
    sytel is on a distinguished road

      0  

    Question How to validate unique record value in RowEditor?

    How to validate unique record value in RowEditor?


    Hi,

    in a grid with RowEditor i have a column:

    Code:
    {
        xtype: 'gridcolumn',
        dataIndex: 'name',
        text: 'Name',
        editor: {
            xtype: 'textfield',
            allowBlank: false
        }
    }
    How do i validate that the 'name' value is unique before updating or inserting a new record?

    Also, if the value is not unique, how can i add an error into errorSummary of RowEditing?

  2. #2
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default


    I am doing something like the following, might not be exactly what you need but could point you in the right direction.

    Example controller
    Code:
    ...
    
    
    refs: [
            {
                ref: 'list',
                selector: 'grid'
            }
    ],
    
    
    init: function() {
    	this.control({
    		'grid': {
    			validateedit: this.validateEdit
    		}
    	});
    },
    
    
    validateEdit: function(plugin, context) {
    	var store = this.getList().getStore(),
    	      key = "name",   // Replace name with the model field name
    	      newName = context.newValues[key],    		   
    	      originalName = context.originalValues[key],    
    	      names = store.collect(key, false);
    
    
    	Ext.Array.remove(names, originalName);
    
    
    	if (Ext.Array.contains(names, newName)) {
    		plugin.editor.down('textfield[name="' + key + '"]').markInvalid("Must be unique.");
    		return false;
    	}
    }
    
    
    ...

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi