1. #1
    Sencha User
    Join Date
    May 2007
    Location
    Frankfurt a. M. / Germany
    Posts
    32
    Vote Rating
    0
    Thorsten is on a distinguished road

      0  

    Default Form Panel and "loader" config

    Form Panel and "loader" config


    Hello all,

    I could use some help with the "loader" config for an Form Panel.

    I want to load some data from the server into the Form (an easy Login Form) at the time it is initialized. So i tried to use the "loader" option like below:
    Code:
    Ext.define('User.view.LoginView', {
    	extend: 'Ext.form.Panel',
    	alias: 'widget.loginview',
    	title: 'Login',
    	bodyPadding: 10,
    	url: '#',
    	layout: 'anchor',
    	defaults: {
    		anchor: '50%'
    	},
    	
    	defaultType: 'textfield',
    	items: [{
    		fieldLabel: 'Login',
    		name: '_username'
    	},{
    		fieldLabel: 'Passwort',
    		name: '_password'
    	},{
    		fieldLabel: 'Benutzer merken',
    		name: '_remember_me',
    		xtype: 'checkbox'
    	},{
    		name: '_csrf_token'
    	}],
    	loader: {
    		url: GlobalData.devUrl + 'login/show.json',
    		autoLoad: true,
    		renderer: 'data'
    	},
    
    	initComponent: function() {
    		this.callParent(arguments);
    	}
    });
    The returned JSON:
    Code:
    { 
    "success": "true",
    "data": {
    		"_csrf_token": "....." ,
    		"_username": "....." 
    	}
    }
    The JSON Data is loaded properly, but the fields are not populated.

    The form is populated properly if I use the "load()" method of the form itself in the Controller. See the code below.
    Code:
    Ext.define('User.controller.ViewportController', {
    	extend: 'Ext.app.Controller',
    	views: [
    		'Viewport',
    		'ProfileView',
    		'LoginView'
    	],
    	stores: [
    		'UserStore'
    	],
    	models: [
    		'UserModel'
    	],
    	init: function() {
    		this.control({
    			'loginview': {
    				beforerender: function(form, opts){
    					form.load({url: GlobalData.devUrl + 'login/show.json'});
    				}
    			}
    			
    		});
    	}
    });
    I can do it this way, but I am not sure if its the best way.

    Another thing that worked in the Loader config was to use "renderer: 'component'". Then new fields were renderer into the form, but without values....

    Maybe someone can explain this behavior to me.

    Many thanks in advance and kind regards,
    Thorsten.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    I would use an ajax call and on success, use loadRecord(record) to add the data to the form.

    Scott.

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