PDA

View Full Version : Get attribute of combobox



itrushn
22 Mar 2010, 12:56 PM
This should be very easy, but I cant seems to figure this out.

I have store which has several parameters defined:


var storeCPU = new Ext.data.ArrayStore({
fields: ['view', 'another'],
data: Ext.configdata.CPU
});


When there is a value selected in this combobox I can use getValue() to access "view" field form the store. Can someone help me with getting "another" parameter/attribute of the selected item.

I am interested in any information. I need it within couple of hours.

Thank you in advance.

itrushn
22 Mar 2010, 3:02 PM
Looks like easiest way for me is to loop through storage data and match “view” field and after that check “another” element data once match is found.

I am not sure how to check elements storage variable. I have array full of elements and each one of them has different storage. For example if I am looking at the array[0] element, how can I look through its storage?

itrushn
23 Mar 2010, 10:10 AM
Can someone please point me in the right direction? I assume that it’s very simple to get values from the store, but don’t understand how.

suryakanth
23 Mar 2010, 10:36 AM
function loadGenderCbx(){

this.gender = new Ext.data.JsonStore({

url : './configcombo/refdata.php' ,

baseParams:{cmd:'GENDER'},

root: 'rows',

fields: ['ATTR_CODE','ATTR_DESC'],

autoLoad: true

});

return this.gender;
}


this.genderComboBox = new Ext.form.ComboBox({
fieldLabel : msgs.gender,
hiddenName: 'GENDER_CD',
store: loadGenderCbx(),
displayField:'ATTR_DESC',
valueField:'ATTR_CODE',
//editable:false,
mode: 'local',
allowBlank: false,
//required: true,
anchor: '60%'
});


so if u say:


this.genderComboBox.getValue();-------> returns code value not description.



if this is not ur expecting then send the code and explan the context clearly

itrushn
23 Mar 2010, 3:40 PM
I have combo:



var storePOW = new Ext.data.ArrayStore({
fields: ['view', 'value', 'buyid', 'stiimage', 'price', 'cost', 'qtyavailable', 'margin', 'disabled', 'defaultselect'],
data: Ext.configdata.POW
});

comboPOW = new Ext.form.ComboBox({
tpl: '<tpl for="."><div class="x-combo-list-item"><b>{view}</b><br />Cost: {cost} | Quantity Available: {qtyavailable} | Profit Percent: {margin}</div></tpl>',
store: storePOW,
displayField: 'view',
valueField: 'price',
width: 600,
typeAhead: true,
forceSelection: true,
mode: 'local',
triggerAction: 'all',
editable: editableBox,
emptyText: 'No Power Cords',
selectOnFocus: true,
applyTo: 'confPOW'
});


Storage is an array:


Ext.configdata.POW = [['Single Power', 'POWER-SERVER', '4831', '94217', '8.00', '1.59', '521', '80.0%', 'false', 'false'],['Y Power Cord', 'POWER-Y-CORD', '4833', '94222', '29.00', '7.07', '48', '76.0%', 'false', 'false']];


Cant get price value:


comboPOW.getValue();


returns "Single Power" instead of "1.59". Why? How can this be fixed?

Also how can I access all other fields?