Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User xava's Avatar
    Join Date
    Mar 2009
    Location
    Argentina
    Posts
    36
    Vote Rating
    0
    xava is on a distinguished road

      0  

    Default I think that i am doing it wrong (valid window with tab and few forms)

    I think that i am doing it wrong (valid window with tab and few forms)


    Edit: i dont know what happend with the paste code, i attached it too

    Hi everybody, i will try to write it short but explained

    i have a view that is a Ext.window.Window component, inside i have a tabpanel and everypanel have a form that are part of the same, i mean:

    the window is a client information, and every tab is part of this client data:

    - Personal data
    - Address data
    - Contact data
    - Observation data

    the view Client.js
    PHP Code:
    Ext.define("AF.view.client.Client", {    extend'Ext.window.Window',        alias'widget.clientview',        title 'Datos del Cliente',    layout'fit',    autoShowtrue,    modaltrue,    width500,    height400,            initComponent: function() {                    this.items = [{                    xtype'tabpanel',                    defaults :{                            border0,                                                        xtype'form',                        border0,                        bodyPadding5,                        waitMsgTargettrue,                        fieldDefaults: {                                    labelWidth140,                                    anchor'100%',                                    msgTarget'side',                                    bindToModeltrue                                }                        },                                            items:[{                            title'Personales',                        items: [                            {                                xtype'textfield',                                name 'name',                                fieldLabel'Nombre'                            },                            {                                xtype'textfield',                                name 'surname',                                fieldLabel'Apellido'                            },                            {                                xtype'textfield',                                name 'dni',                                fieldLabel'DNI'                            },                            {                                xtype'datefield',                                name 'birthday',                                fieldLabel'Fecha de Nacimiento'                            }                        ]                },{                        title'Domicilio',                                                                        items: [                            {                                xtype'textfield',                                name 'city',                                fieldLabel'Ciudad'                            },{                                xtype'textareafield',                                name 'address',                                fieldLabel'Calle:<br />Numero:<br />Piso, Dpto',                                height100,                                growtrue                            }                        ]                },{                        title'Contacto',                                                                        items: [                            {                                xtype'textfield',                                name 'email',                                fieldLabel'Email'                            },{                                xtype'textfield',                                name 'telephone',                                fieldLabel'Telefono'                            },{                                xtype'textfield',                                name 'cellphone',                                fieldLabel'Celular'                            }                        ]                },{                        title'Observaciones',                        layout'fit',                        items: [                            {                                xtype'textareafield',                                name 'observations',                                fieldLabel'Observaciones',                                hideLabeltrue                                                           }                        ]                }]            }        ];         this.buttons = [            {                text'Aceptar',                action'accept'            },            {                text'Cancelar',                scopethis,                handlerthis.close            }        ];         this.callParent(arguments);    }}); 
    i want validate all the form and if some field is invalid mark it (actually i validate the form via model and i add extra ux to merge model validation to form validation)

    taken from this forum (that is not importat actually, but i want give all the information)
    PHP Code:

    Ext
    .define('Ext.ux.form.Basic', {                override'Ext.form.Basic',                        loadRecord: function(record) {            var me this;            me._validationRecord record.copy();            me.callOverridden(arguments);            me.monrecord'changed'me.onRecordChangedme );        },        onRecordChanged: function(){            this.loadRecordthis.getRecord() );        }    });        Ext.define('Ext.ux.form.field.Base', {            override'Ext.form.field.Base',                    getErrors: function() {            var me this,                errors me.callOverridden(arguments),                record me.up('form').getForm()._validationRecord,                                        modelValidations,                 fieldValidations;                              if (!me.bindToModel || !record) return errors;                            modelValidations record.validate();              if (modelValidations.isValid()) {                  return errors;              }                            fieldValidations modelValidations.getByField(me.name);              fieldValidationsLength fieldValidations.length;                            if (fieldValidationsLength 0) {                  for (var 0fieldValidationsLengthj++) {                      errors.push(fieldValidations[j].message);                  }                                    }                            return errors;        },                onChange: function() {                var me this,                form me.up('form').getForm(),                record form.getRecord();                                if (me.bindToModel && record && (me.name in record.data)) {                  record.beginEdit();                  record.set(me.nameme.getValue());                  record.endEdit();                }                                this.callOverridden(arguments);          }      /*        onChange: function() {            var me = this,            form = me.up('form').getForm(),            record = form._validationRecord;

                if (me.bindToModel && record && (me.name in record.data)) {                record.beginEdit();                record.set(me.name, me.getValue());                record.endEdit();            }

                this.callOverridden(arguments);        }        */    
    }); 
    and this is my controller, al use componentQuery to take all the forms from the window and i merge all the values to load in the model, later if model is not valid call getForm().isValid() to mark the field invalid in the tabs

    controller NewClient.js
    PHP Code:
    Ext.define('AF.controller.menu.client.NewClient', {    extend'Ext.app.Controller',        requires:[            'AF.view.client.Client'        ],        models: [            'Client'    ],        init: function() {            if(AF.debug)                    console.log('Load: AF.controller.menu.client.NewClient');                        this.control({                        'clientview button[action=accept]': {                                'click'this.onAcceptClick                        }            })    },        loadView: function() {            var view Ext.widget('clientview');    },        onAcceptClick: function(button) {            var win    button.up('window'),        forms   win.query('form');                       // merge all the forms values        var values = {};        Ext.Object.each(forms, function(key, form){                values = Ext.Object.merge(values, form.getValues());                // important to show invalid the field in the form                form.getForm().isValid();        });                        // load the values and create the model        var clientModel = this.getClientModel();        var client = new clientModel(values); //.save();                    // if model is valid save the model        // if not mark the invalid field in the forms        if(client.isValid()) {                console.log('model: true');    
                            
    client.save();        }         else         {                console.log('model: false');                                Ext.Object.each(forms, function(keyform){                        // important to show invalid the field in the form                        form.getForm().loadRecord(client);                        form.getForm().isValid();                });        }                                   }}); 
    and this is the model Client.js
    PHP Code:
    Ext.define('AF.model.Client', {    extend'Ext.data.Model',        fields: [        { name'id'type'int' },        { name'name'type'string' },        { name'surname'type'string' },        { name'dni'type'string' },        { name'email'type'string' },        { name'birthday'type'date' },        { name'city'type'string' },        { name'address'type'string' },        { name'telephone'type'string' },        { name'cellphone'type'string' },        { name'observations'type'string' }    ],        validations: [            { type'presence'field'name' },            { type'presence'field'city' }    ],        proxy: {        type'rest',        url'/server',        reader: {            type'json',            root'results'        }    }}); 
    Issues: if the user didn't click in a tab panel, if there is in this form some invalid field the getForm().isValid() didn't mark the field, is like the form is not loaded, if the user click in the tab and later go to accept in every tab that clicked if there is a invalid form field mark it

    i am doing it right? of there is another better way to implement a multi-form in one windows with tab and valid all ?

    Thanks you
    Attached Files

  2. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    85
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    If all the panels of the TabPanel belong to the same form, I'd just use one form (the tabpanel can be an item of it, and then still distribute the fields across the various tabs, instead of using a form for each tab. That way, you don't have to validate multiple forms, and you don't have to merge a bunch of values from different forms into one, just to populate your model.

    RE: the lack of validation of unopened tabs, this is because the TabPanel defers rendering each tab until they are activated. This is the default config. So it's not just that it's *like* the form isn't rendered...that, in fact, is precisely what is happening.

    To overcome this, you can set deferredRender to false, and each tab will be immediately rendered along with the TabPanel. Here are the docs for this config: http://docs.sencha.com/extjs/4.2.0/#...deferredRender

    Hope this helps!

  3. #3
    Sencha User xava's Avatar
    Join Date
    Mar 2009
    Location
    Argentina
    Posts
    36
    Vote Rating
    0
    xava is on a distinguished road

      0  

    Default


    yes, for sure! thanks you so much!!
    i will try do all one form!

Thread Participants: 1

Tags for this Thread