1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    2
    Vote Rating
    0
    Natal'ia is on a distinguished road

      0  

    Default "Combo with Templates and Ajax" and xtype

    "Combo with Templates and Ajax" and xtype


    Hi!
    I've used an exemple http://dev.sencha.com/deploy/ext-4.1...um-search.html.
    And it works (see code)

    Code:
    Ext.namespace("Ext.app.com");
    
    
        Ext.app.com.Search = Ext.extend(Ext.form.ComboBox, {
        initComponent: function(){
            Ext.apply(this, {
                store: ds,
                minChars: 1,//The number of charcters before autocomplete and typeAhead activate (defaults to 4)
                displayField:'name',
                typeAhead: false,
                loadingText: 'Searching...',
                width: 570,
                pageSize:10,
                hideTrigger:true,           
                applyTo: 'search',  
                tpl: resultTpl,//The name of element in html-file
                itemSelector: 'div.search-item'//The name of my template (see up)
             })
    
    
             Ext.app.com.Search.superclass.initComponent.apply(this, arguments);
        }
        });
    
    
        Ext.reg("searchCB", Ext.app.com.Search);
    
    var search = new Ext.app.com.Search({
            renderTo: bd
        });
    Code:
     <input type="text" size="40" name="search" id="search" />
    But if I write as xtype it doesn't work. (see code)

    Code:
    var gridForm2 = new Ext.FormPanel({        id: 'goods-form2',
            frame: true,
            labelAlign: 'left',
    
    
            bodyStyle:'padding:15px',
            width: 750,
            layout: 'absolute',    // Specifies that the items will now be arranged in columns
            items: [
                    {
                        items: {
                            xtype: 'searchCB',
                            name: 'search1',
                            fieldLabel: 'search1'
                        }
                    },{
                        buttons: [{
                            //text: '+',
                            width : 24,
                            height: 24,
                            icon: 'js/icons/add.gif',
                            style: {
                                padding: '1px'
                            }
                        }]
                    }
                ],
            renderTo: bd
        });
    What's wrong?
    Thanks.

  2. #2
    Sencha User
    Join Date
    Jan 2011
    Posts
    546
    Vote Rating
    52
    willigogs is a jewel in the rough willigogs is a jewel in the rough willigogs is a jewel in the rough

      0  

    Default


    Why do you have items within items in your formpanel?

    Unless specified otherwise, the default item within a formpanel will be a textField - therefore you seem to be attempting to make your combo the child item of a textField (and textFields do not support having items).

    You also have buttons within your items, which again is not correct.

    I'm assuming your code should really be like the following:
    Code:
    var gridForm2 = new Ext.FormPanel({
        id: 'goods-form2',
        frame:true,
        bodyStyle:'padding:15px',
        width: 750,
        renderTo: bd,
        layout:'form',
        defaultType: 'textfield',
        items: [{
            xtype: 'searchCB',
            name: 'search1',
            fieldLabel: 'search1'
        }],
        buttons: [{
            //text: '+',
            width : 24,
            height: 24,
            icon: 'js/icons/add.gif',
            style: {
                padding: '1px'
            },
            handler: function() {
               alert('Click')
            }
        }]
    });

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    2
    Vote Rating
    0
    Natal'ia is on a distinguished road

      0  

    Default


    Many thanks, willigogs.
    You're right.

Thread Participants: 1