-
24 Mar 2011 10:48 AM #1
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.
-
24 Mar 2011 2:02 PM #2
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...
-
24 Mar 2011 2:04 PM #3
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
-
24 Mar 2011 2:09 PM #4
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 });
-
24 Mar 2011 2:26 PM #5
/// 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.
-
24 Mar 2011 2:58 PM #6
That should be fine, simply have 5 selects all with store: myStore
-
24 Mar 2011 3:14 PM #7
///////////////////
//// 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')
-
24 Mar 2011 3:20 PM #8
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 }] }] }] });
-
25 Mar 2011 7:30 AM #9
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
-
(Newbie) Remote load combo options and select an item
By ziggurat in forum Ext 2.x: Help & DiscussionReplies: 11Last Post: 26 Dec 2011, 12:55 AM -
Selected item in select (dropdown menu).
By ediew in forum Sencha Touch 1.x: DiscussionReplies: 0Last Post: 27 Jul 2010, 4:12 AM -
How To Select Item In A Combo Then Trigger Load Or Select In Another Combo ??
By chalu in forum Ext GWT: DiscussionReplies: 2Last Post: 12 Jul 2010, 9:20 AM -
How to return the cursor after select a menu item?
By kohyea in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 2 Dec 2009, 10:06 PM -
select item in a view when object is hold in memory
By steffenk in forum Ext 1.x: Help & DiscussionReplies: 8Last Post: 24 Aug 2007, 1:10 PM


Reply With Quote