[CLOSED] get record values of the selected combobox item

  1. #1

    [CLOSED] get record values of the selected combobox item

    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>
    Last edited by Daniil; Jun 26, 2012 at 9:13 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Quote Originally Posted by marco.morreale View Post
    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);" />

Similar Threads

  1. Replies: 1
    Last Post: Jan 19, 2012, 12:11 PM
  2. Replies: 2
    Last Post: Sep 04, 2011, 4:51 PM
  3. Replies: 2
    Last Post: Oct 03, 2010, 12:06 PM
  4. [CLOSED] How to change record values of selected rows?
    By macap in forum 1.x Premium Help
    Replies: 6
    Last Post: Jul 30, 2010, 12:29 PM
  5. [CLOSED] ComboBox set selected item value
    By pumpkin in forum 1.x Premium Help
    Replies: 1
    Last Post: Sep 27, 2009, 7:26 AM

Posting Permissions