1. #1
    Ext User
    Join Date
    Aug 2007
    Posts
    212
    Vote Rating
    0
    djfiii is on a distinguished road

      0  

    Default ComboBox - JSON popluated

    ComboBox - JSON popluated


    I've read every tutorial AND the two books I have (Learning EXTJS and EXTJS in action MEAP version) and can't get the basic example of a combo box that's built with JSON data to work.

    Here's the JSON being returned by roles.php

    Code:
    {records : [{"roleid":"1","role":"Trader"},{"roleid":"2","role":"Manager"},{"roleid":"3","role":"Super User"}]}
    Here I've got my data store:
    Code:
    var remoteStore = new Ext.data.Store({
    	reader : new Ext.data.JsonReader({
    		fields : ['roleid','role'],
    		root : 'records'  
    	}),
    	proxy : new Ext.data.HttpProxy({
    		url : 'roles.php'
    	}),
    	autoLoad : true
    });
    And here I've got my form (combo is at the bottom).

    Code:
    var userForm = new Ext.FormPanel({
    	id       : 'centerPanelContent',
    	title    : 'Edit User',
    	width    : 400,
    	padding  : '5 5 5 5',
    	defaults : { xtype : 'textfield', width : 200, allowBlank : false },
    	items    : [{
    		fieldLabel : 'First Name',
    		name : 'firstname',
    	},{
    		fieldLabel : 'Last Name',
    		name : 'lastname'	
    	},{
    		fieldLabel : 'User Name',
    		name : 'username'		
    	},{
    		fieldLabel : 'Email',
    		name : 'email',
    		vtype : 'email'
    	},{
    		fieldLabel : 'Phone Number',
    		name : 'phone'			
    	},{
    		xtype: 'combo',
    		fieldLabel : 'Role',
    		store : remoteStore,
    		displayField : 'role',
    		valueField : 'roleid'
    		
    	}]		
    });
    Based on every example I've seen, this should work. The combo shows up in the form, but there is no data in it. Am I missing something obvious? A second set of eyes would be much appreciated at this point.

    Thanks!

  2. #2
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    673
    Vote Rating
    20
    carol.ext will become famous soon enough carol.ext will become famous soon enough

      0  

    Default


    Is the store loading? Use the debugger, add load and exception handlers.

  3. #3
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750
    Vote Rating
    9
    fay will become famous soon enough fay will become famous soon enough

      1  

    Default


    It works for me when I add in mode and triggerAction config params:

    Code:
    xtype: 'combo',
    fieldLabel : 'Role',
    store : remoteStore,
    mode: 'local', // <--
    triggerAction: 'all', // <--
    displayField : 'role',
    valueField : 'roleid'

  4. #4
    Ext User
    Join Date
    Jan 2008
    Location
    Cambridge UK
    Posts
    41
    Vote Rating
    1
    emily is on a distinguished road

      0  

    Default


    I am having a similar problem, but just with an ArrayStore. The data is fetched from the server and returns alright, and if I examine the form object I can see all the data etc, but it just isn't rendering!!

    GRRRRRR

  5. #5
    Ext User
    Join Date
    Aug 2007
    Posts
    212
    Vote Rating
    0
    djfiii is on a distinguished road

      0  

    Default


    ok - I did what fay suggested and it works for me now that I've added mode and triggerAction too. I thought mode : 'local' was for data stores that were not populated via httpproxy, i.e. "local" (static) stores? And I'm not even sure what triggerAction does. I'll check the API.

    Thanks again!

  6. #6
    Ext User
    Join Date
    Jan 2008
    Location
    Cambridge UK
    Posts
    41
    Vote Rating
    1
    emily is on a distinguished road

      0  

    Default


    I finally got it working too, and it was the triggerAction that did it.

    It would be useful if the docs gave more of a clue about what options are required and what are optional because this was pretty hard to debug.

Thread Participants: 3

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