PDA

View Full Version : Confused about Combobox with hiddenName



missgextjs
23 Sep 2010, 1:45 AM
Now I'm working on extjs + php about insert/update page. In my each page have many combobox (example City) which get data from remote datastore.

My problem is :

1. About Insert page - I can display list of City and get city id by calling hiddenName ( in php --> $_POST['cityID'])to save to database completely.

this is my code:

cityIDField = new Ext.form.ComboBox({
id: 'cityIDField',
name: 'city_id',
hiddenName: 'cityID',
fieldLabel: 'City',
disabled: false,
triggerAction: 'all',
typeAhead: true,
mode: 'remote',
store: CityDataStore,
valueField: 'id',
displayField: 'city_name',
emptyText: 'Select City ...',
selectOnFocus: true,
allowBlank: false
});

But when I call php to query city data I got city_id NOT city_name ( in php --> select a.partnerid, a.city_id from xxx )

I solved problem by get city_name from city table using a.city_id to finding city_name then display in editable page

below is my code:

edit_cityIDField = new Ext.form.ComboBox({
id: 'edit_cityIDField',
name: 'city_id',
hiddenName: 'city_name',
fieldLabel: 'City',
disabled: false,
triggerAction: 'all',
typeAhead: true,
mode: 'remote',
store: CityDataStore,
valueField: 'id',
displayField: 'city_name',
emptyText: 'Select City ...',
selectOnFocus: true,
allowBlank: false
});


It's work when I changed to other city BUT when I didn't change this filed .. In my table I got city_name NOT city_id. So when I click on update button then in my table get name NOT id.


Anyone can help me to solved this problem .. I need to clearify that how combobox working.

I'm newbie in english and extjs .. please help :(

Many Thanks

troseberry
23 Sep 2010, 4:25 AM
Please try to wrap all your "code" snippets in the CODE tags (# button)

laurentParis
23 Sep 2010, 4:30 AM
edit_cityIDField = new Ext.form.ComboBox(
{
id: 'city_id', // for most clarity on your head, set id and name with 'city_id'
name: 'city_id',

hiddenId: 'city_name', // again, use for hiddenId and hiddenName 'city_name'
hiddenName: 'city_name',

hiddenValue: 'city_name', // => this element is send to php on saved operation with combobox hiddenName => $city_name = 'Paris' (city_name->'Paris')
valueField: 'id', // => this element is send to php on saved operation with combobox name => $city_id = 36 (id->36)

displayField: 'city_name', // =>displayField is not send to server (php doesn't see this element)

fieldLabel: 'City',
disabled: false,
triggerAction: 'all',
typeAhead: true,
mode: 'remote',
store: CityDataStore,
emptyText: 'Select City ...',
selectOnFocus: true,
allowBlank: false
});

missgextjs
26 Sep 2010, 9:42 PM
Perfectly !!!!! :D

It's work .. Many Thanks troseberry .. especially laurentParis - thank you about your kindly description :D







edit_cityIDField = new Ext.form.ComboBox(
{
id: 'city_id', // for most clarity on your head, set id and name with 'city_id'
name: 'city_id',

hiddenId: 'city_name', // again, use for hiddenId and hiddenName 'city_name'
hiddenName: 'city_name',

hiddenValue: 'city_name', // => this element is send to php on saved operation with combobox hiddenName => $city_name = 'Paris' (city_name->'Paris')
valueField: 'id', // => this element is send to php on saved operation with combobox name => $city_id = 36 (id->36)

displayField: 'city_name', // =>displayField is not send to server (php doesn't see this element)

fieldLabel: 'City',
disabled: false,
triggerAction: 'all',
typeAhead: true,
mode: 'remote',
store: CityDataStore,
emptyText: 'Select City ...',
selectOnFocus: true,
allowBlank: false
});