Ext.onReady(function(){

    var ds = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: './inc/ajax/getsearch.php'
        }),
        reader: new Ext.data.JsonReader({
            root: 'products',
            //totalProperty: 'total',
            id: 'id'
        }, [
            {name: 'id', mapping: 'id'},
            {name: 'title', mapping: 'title'},
            {name: 'url', mapping: 'url'}
        ])
    });

    // Custom rendering Template
    var resultTpl = new Ext.XTemplate(
        '<tpl for="."><div class="search-item">',
            '<div style="line-height: 15px;">{title}</div>',
        '</div></tpl>'
    );
    
    var search = new Ext.form.ComboBox({
        store: ds,
        displayField:'title',
        typeAhead: false,
        loadingText: 'Hledám...',
        minChars: 1,
        cls: 'extjscombo',
        width: 180,
        //pageSize:20,
        hideTrigger:true,
        tpl: resultTpl,
        applyTo: 'search',
        itemSelector: 'div.search-item',
        forceSelection: false,
        selectOnFocus: false,
        editable:true, 
        onSelect: function(record){
            var path =  ''+record.data.url+'.html';
            document.location.href = path;
            this.collapse();
        }

    });

});