1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    18
    Answers
    2
    Vote Rating
    1
    neoraptor is on a distinguished road

      0  

    Default Unanswered: Dynamic fields and validation in model

    Unanswered: Dynamic fields and validation in model


    Hello,

    I would like to build a model from data coming from server. Is it possible to do it?

    My objective is to add new fields and validations to an existing model.

    Examples: current model:
    Code:
    Ext.define('MyApp.model.userModel', {
        extend: 'Ext.data.Model',
        xtype: 'userModel',
    	
        config: {
            fields: [
    			{ name: 'name', type: 'string' },
    			{ name: 'age', type: 'int'}, 
            ],
    		validations: [
    			{type: 'presence', field: 'name'},
    			{type: 'presence', field: 'age'},
    		]
        }
    });
    For the moment, I managed to retrieve the model using the model manager (Ext.ModelManager.getModel('MyApp.model.userModel'), but I can't access its properties (fields and validations items).
    How could I do that?

    Thank you for your answers

  2. #2
    Sencha User
    Join Date
    Jun 2012
    Posts
    18
    Answers
    2
    Vote Rating
    1
    neoraptor is on a distinguished road

      0  

    Default


    I tried various methods without success :
    * There is no activate events where I can define it dynamically
    * I tried to build a model dynamically and attached it to the store

    Is it possible to do it? What am I missing?

    Thank you for your support

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    18
    Answers
    2
    Vote Rating
    1
    neoraptor is on a distinguished road

      1  

    Default


    Small update : I found this method to work :

    Code:
    // get Model
    var myModel = Ext.ModelManager.getModel('PhoneGap.model.patientModel');
    // Retrieve newFields dynamically
    var newFields = [];
    newFields = eval(store.getCustomFields());
    // Add each of the new field in the model
    for (var i = newFields.length - 1; i >= 0; i--){
    	 myModel.prototype.fields.add(new Ext.data.Field(newFields[i]));
    };
    Hope it can help someone

  4. #4
    Sencha User
    Join Date
    Jan 2014
    Location
    Mumbai
    Posts
    11
    Vote Rating
    0
    punitm is on a distinguished road

      0  

    Default


    i want to create dynamic model. According to this method model has been created but after that my store is not loading.Here is my code please help me
    var newFields = ['PTYPE','MailSub','Status'];
    // Add each of the new field in the model
    var myModel = Ext.ModelManager.getModel('MYApp.model.ModelBooking');
    for (var i = 0; i<newFields.length; i++){
    myModel.prototype.fields.add(new Ext.data.Field(newFields[i]));
    };



    Ext.getCmp('MyBookingListID').getStore().removeAll();
    var paymentURL = '../13/csv-json.php?name=PO.csv';
    Ext.getCmp('MyBookingListID').getStore().setProxy({
    url: paymentURL,
    });
    Ext.getCmp('MyBookingListID').getStore().load();

  5. #5
    Sencha User nareshkokkula's Avatar
    Join Date
    Feb 2012
    Posts
    43
    Answers
    1
    Vote Rating
    -3
    nareshkokkula can only hope to improve

      0  

    Default How can I add validations dynamically

    How can I add validations dynamically


    Can someone please help me to add validations dynamically.

    I'm trying in this way..

    Code:
    model.prototype.validations.add(new Ext.data.Validations.setPresenceMessage(controlArray[k]._name + " is required field."));

Thread Participants: 2

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..."