PDA

View Full Version : [CLOSED] get record values of the selected combobox item



marco.morreale
Jun 20, 2012, 10:05 AM
Hi,
I am trying to call my prepareListItems function wich needs an index parameter representing the selected index of my combobox.

I also tried:



<Select Handler="Sauflon.SlowOrder.prepareListItems(records, #{cbConfezioniProdotto}.getSelectedIndex())" />


but i get an error.

What is the best way to get the selected index of a combobox?
How can I get the store record bound to the combo selected item?
M






<ext:XScript ID="XScript1" runat="server">
<script type="text/javascript">
Ext.ns('Sauflon.SlowOrder');
Sauflon.SlowOrder = {
prepareListItems: function (records,index) {

if (records.length > 0) {
var data = [];
var itemValue = {
Quantitaminima: records[index].data.Quantitaminima,
Quantitamultipla: records[index].data.Quantitamultipla,
ProductNumber: records[index].data.Productnumber
};
data.push(itemValue);
return (Ext.encode(data));
}
else return null;
}
}
</script>
</ext:XScript>

<ext:ComboBox ID="cbConfezioniProdotto" runat="server" DisplayField="Description" ValueField="Code" >
<Store>
<ext:Store ID="stConfezioniProdotto" runat="server" PageSize="10" AutoLoad="false" >
<Proxy>
<ext:AjaxProxy Json="true" Url="../WebServices/AjaxWebService.asmx/getConfezioniProdottoLiquidi">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="d.Data" TotalProperty="d.Total" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Code" />
<ext:ModelField Name="Description" />
<ext:ModelField Name="Quantitaminima" Type="Int" />
<ext:ModelField Name="Quantitamultipla" Type="Int" />
<ext:ModelField Name="Productnumber" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Listeners>
<Select Handler="Sauflon.SlowOrder.prepareListItems(records, index)" />
</Listeners>
</ext:ComboBox>

Daniil
Jun 20, 2012, 1:22 PM
Hi,



What is the best way to get the selected index of a combobox?
How can I get the store record bound to the combo selected item?


I can suggest the following solution.

Example

var comboBox = App.ComboBox1,
value = comboBox.getValue();
record = comboBox.findRecordByValue(value),
index = comboBox.getStore().indexOf(record);

Within a Select listener it can look like this.

Example

<Select Handler="var record = records[0];
index = this.getStore().indexOf(record);

alert(index);" />