How to get the ComponentColumn's value?

  1. #1

    How to get the ComponentColumn's value?

    Hello,All,I have used a componentColumn,and in the componentColumn,I added a ComboBox in it,the code is as this:
                    <ext:ComponentColumn ID="colItemCode" runat="server" Editor="true" DataIndex="StockPrice"
                        Text="<font color=blue>Item</font>" Width="120px">
                        <Component>
                            <ext:ComboBox ID="cbItemCode" runat="server" EmptyText="Select a item" StoreID="Store2"
                                TypeAhead="true" ForceSelection="true" DisplayField="ITEM_CODE" ValueField="ITEM_CODE"
                                MinChars="1" MatchFieldWidth="false" PageSize="10" Editable="false">
                                <ListConfig Width="400" Height="300" ItemSelector=".x-boundlist-item">
                                    <Tpl ID="Tpl1" runat="server">
                                        <Html>
                                        <tpl for=".">
                                                    <tpl if="[xindex] == 1">
                                                        <table class="cbItems-list">
                                                            <tr>
                                                                <th>Code</th>
                                                                <th>Name</th>
                                                                <th>Spec</th>
                                                                <th>Unit</th>
                                                            </tr>
                                                    </tpl>
                                                    <tr class="x-boundlist-item">
                                                        <td>{ITEM_CODE}</td>
                                                        <td>{ITEM_NAME}</td>
                                                        <td>{ITEM_SPEC}</td>
                                                        <td>{UNIT}</td>
                                                    </tr>
                                                    <tpl if="[xcount-xindex]==0">
                                                        </table>
                                                    </tpl>
                                                </tpl>
                                        </Html>
                                    </Tpl>
                                </ListConfig>
                                <Triggers>
                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                </Triggers>
                                <Listeners>
                                    <BeforeQuery Handler="this.getTrigger(0)[this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                    <TriggerClick Handler="if (index == 0) { 
                                                                   this.focus().clearValue(); 
                                                                   trigger.hide();
                                                               }" />
                                    <Select Handler="selectHandler(#{cbItemCode},#{Store1});" />
                                </Listeners>
                            </ext:ComboBox>        
                        </Component>
                    </ext:ComponentColumn>
    Then I use a function to get the combbox's value,I use this code:
           var selectHandler = function(combox, store)
            {
                alert(combox);
                var itemCode = combox.value;
                App.GridPanel1.body.mask('Loading...');
                InboundX.QueryStore(itemCode, {
                    success: function(rs)
                    {
                        store.getAt(0).set('ItemID', rs[0]);
                        //store.getAt(0).set('ItemCode', rs[1]);
                        store.getAt(0).set('ItemName', rs[2]);
                        store.getAt(0).set('ItemSpec', rs[3]);
                        store.getAt(0).set('ItemBarcode', rs[4]);
                        store.getAt(0).set('ItemUnit', rs[5]);
                        store.getAt(0).set('CurrentStock', rs[6]);
                        store.getAt(0).set('StockPrice', rs[7]);
                        store.getAt(0).set('SellingPrice', rs[8]);
                        store.getAt(0).set('InStockQty', rs[9]);
                    },
                    complete: function(rs)
                    {
                        App.GridPanel1.body.unmask();
                    },
                    error: function()
                    {
                        App.GridPanel1.body.unmask();
                    }
                });
            };
    But the combbox will alert "undefined",how can I get the combbox's value?
    Last edited by geoffrey.mcgill; Apr 13, 2013 at 4:14 PM.
  2. #2
    Hi @kulolo,

    An array of selected records is passed to a Select listener.
    http://docs.sencha.com/ext-js/4-2/#!...x-event-select

    Example
    <Select Handler="alert(records[0].data[this.valueField]);">
    Also I don't think that you can use #{cbItemCode} of the ComponentColumn's ComboBox, because it renders a new ComboBox for each row and uses some unique ids, i.e. auto generate them.
  3. #3
    Thanks very much for your response,it can work now.!!

Similar Threads

  1. [CLOSED] ComponentColumn TriggerField setValue
    By CPA1158139 in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 08, 2013, 2:44 AM
  2. [CLOSED] ComponentColumn
    By canbay in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 26, 2012, 7:56 PM
  3. [CLOSED] ComponentColumn
    By canbay in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 10, 2012, 5:26 PM
  4. ComponentColumn Editor Bug?
    By Doug.Morrow in forum 2.x Help
    Replies: 6
    Last Post: Aug 08, 2012, 7:30 PM
  5. ComponentColumn usage
    By Zdenek in forum 2.x Help
    Replies: 0
    Last Post: Jul 13, 2012, 9:38 AM

Posting Permissions