1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    18
    Vote Rating
    0
    mailboxo71 is on a distinguished road

      0  

    Default How to pre-populate a Select menu UI item on Load of the Card (View)

    How to pre-populate a Select menu UI item on Load of the Card (View)


    Hi,

    I like to know this, is there a way to pre-populate a Select menu UI item on Load of a Card that its in.

    It like this, my app has a main menu that contains a button that pulls up the member settings card (screen) that contains a number of Select Menu UI items that I want to pre-populate with data from the database. Please let me know if thats possible and doable.

    thanks in advance.

  2. #2
    Sencha User d5chris's Avatar
    Join Date
    Feb 2011
    Location
    Sydney
    Posts
    59
    Vote Rating
    2
    d5chris is on a distinguished road

      0  

    Default


    If you're using a Ext.form.Select, it has a 'store' property for just this purpose, so you should be able to do that. Eg set up a model and store to pull from your database, and bind the select to that store. Something like that...

  3. #3
    Sencha User
    Join Date
    Dec 2010
    Posts
    18
    Vote Rating
    0
    mailboxo71 is on a distinguished road

      0  

    Default


    Sounds easy enough but there's no sample code that actually shows how to do what you said. Especially from a Database.

    Thanks anyway. but I do need sample codes

  4. #4
    Sencha User d5chris's Avatar
    Join Date
    Feb 2011
    Location
    Sydney
    Posts
    59
    Vote Rating
    2
    d5chris is on a distinguished road

      0  

    Default


    Sure:

    Code:
    Ext.regModel('MyOption', {
        fields: [
            {name: 'text', type: 'string'},
            {name: 'value',  type: 'string'}
        ]
    });
    
    var myStore = new Ext.data.Store({
        model: 'MyOption',
        proxy: {
            type: 'ajax',
            url : '/return-my-options-from-database.json.php',
            reader: {
                type: 'json',
                root: 'users'
            }
        },
        autoLoad: true
    });
    ...
    new Ext.form.Select({
        store: myStore,
        displayField: 'text', // This is the default and you could remove it
        valueField: 'value' // Ditto
    });

  5. #5
    Sencha User
    Join Date
    Dec 2010
    Posts
    18
    Vote Rating
    0
    mailboxo71 is on a distinguished road

      0  

    Default


    /// Here's my additional dilemma that I still need help.
    /// There are like five select menus that will display all the same data from the store.

    /// Here's the thing, each select menu will have a different selected item base on user settings store
    in the database.

    I can tell you now, the items are a list of neighborhoods and the each select menu will have a different
    neighborhood pre-selected onLoad of the card.

    I know how to do this in regular website in PHP, but I definately have trouble doing it with this framework.

  6. #6
    Sencha User d5chris's Avatar
    Join Date
    Feb 2011
    Location
    Sydney
    Posts
    59
    Vote Rating
    2
    d5chris is on a distinguished road

      0  

    Default


    That should be fine, simply have 5 selects all with store: myStore

  7. #7
    Sencha User
    Join Date
    Dec 2010
    Posts
    18
    Vote Rating
    0
    mailboxo71 is on a distinguished road

      0  

    Default


    ///////////////////
    //// My code does the rendering a little different.

    I don't use this

    new Ext.form.Select({
    store: myStore,
    displayField: 'text',
    valueField: 'value'

    });





    Instead my select menus are specified by a FormPanel like so.


    form = new Ext.form.FormPanel({
    items: [
    {
    xtype: 'fieldset',
    title: 'Edit Message Pref.',
    instructions: 'Edit your Settings',
    defaults: {
    required: true,
    labelAlign: 'left',
    labelWidth: '40%'
    },
    items: [
    {
    xtype: 'fieldset',
    title: 'General - Entire City',
    items: [
    {
    xtype: 'checkboxfield',
    Align: 'left',
    name: 'cc0',
    value: true
    }

    ]
    },


    ]

    });






    //// The problem is i don't instantiate the Ext.form.Select but instead specify as an item...

    /// Is there a way to do the same thing as I have specify in my code...

    Please note, I am using (xtype: 'selectfield')

  8. #8
    Sencha User d5chris's Avatar
    Join Date
    Feb 2011
    Location
    Sydney
    Posts
    59
    Vote Rating
    2
    d5chris is on a distinguished road

      0  

    Default


    Yes, the way you're doing it is more realistic: xtypes inside a formpanel. So you'd have something like:

    Code:
    form = new Ext.form.FormPanel({
    	items: [{
    		xtype: 'fieldset',
    		title: 'Edit Message Pref.',
    		instructions: 'Edit your Settings',
    		defaults: { 
    			required: true,
    			labelAlign: 'left',
    			labelWidth: '40%'
    		},
    		items: [{
    			xtype: 'fieldset',
    			title: 'General - Entire City',
    			items: [{
    				xtype: 'checkboxfield',
    				Align: 'left',
    				name: 'cc0',	
    				value: true
    			}, {
    				xtype: 'selectfield1',
    				store: myStore,
    				displayField: 'text',
    				valueField: 'value'
    			}, {
    				xtype: 'selectfield2',
    				store: myStore
    			}]
    		}]
    	}]
    });

  9. #9
    Sencha User
    Join Date
    Dec 2010
    Posts
    18
    Vote Rating
    0
    mailboxo71 is on a distinguished road

      0  

    Default


    Here's my addtional dilemma,

    In addtion to loading the options to the menus, I need to make the menus show the user's saved selection from the database. I don't know how to do the following.


    1. How do I make a 2nd php call to retrieve the JSON. (I know how to write the PHP file that retrieves and spits out the JSON of the user's selection.

    2. How do I parse the JSON receive and set the menu so it shows the user's saved selection of the menu.

    In other words, when all the menus have loaded the options, I need the menu to show the user's saved selection of the menus.

    I sincerely thank all the help.

    Thanks

Similar Threads

  1. (Newbie) Remote load combo options and select an item
    By ziggurat in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 26 Dec 2011, 12:55 AM
  2. Selected item in select (dropdown menu).
    By ediew in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 27 Jul 2010, 4:12 AM
  3. Replies: 2
    Last Post: 12 Jul 2010, 9:20 AM
  4. How to return the cursor after select a menu item?
    By kohyea in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 2 Dec 2009, 10:06 PM
  5. select item in a view when object is hold in memory
    By steffenk in forum Ext 1.x: Help & Discussion
    Replies: 8
    Last Post: 24 Aug 2007, 1:10 PM

Thread Participants: 1

Tags for this Thread

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