Combo with Templates and Ajax : ComboBox « Ext JS « JavaScript DHTML

Combo with Templates and Ajax


 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>

<!-- The box wrap markup embedded instead of using Element.boxWrap() -->
<div style="width:600px;">
    <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
    <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">
        <h3 style="margin-bottom:5px;">Search the Ext Forums</h3>
        <input type="text" size="40" name="search" id="search" />
        <div style="padding-top:4px;">
            Live search requires a minimum of 4 characters.
    <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>

<!-- Revised from demo code in ext3.0.0 -->
<script type="text/javascript">

 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC

    var ds = new{
        proxy: new{
            url: ''
        reader: new{
            root: 'topics',
            totalProperty: 'totalCount',
            id: 'post_id'
        }, [
            {name: 'title', mapping: 'topic_title'},
            {name: 'topicId', mapping: 'topic_id'},
            {name: 'author', mapping: 'author'},
            {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
            {name: 'excerpt', mapping: 'post_text'}

    // Custom rendering Template
    var resultTpl = new Ext.XTemplate(
        '<tpl for="."><div class="search-item">',
            '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>{title}</h3>',
    var search = new Ext.form.ComboBox({
        store: ds,
        typeAhead: false,
        loadingText: 'Searching...',
        width: 570,
        tpl: resultTpl,
        applyTo: 'search',
        itemSelector: '',
        onSelect: function(record){ // override default onSelect to do redirect
            window.location =



Related examples in the same category

1.Add combobox to a window and set width
2.Set up combobox field
3.Indicate display field for a ComboBox and SimpleStore
4.Load data from server and feed into ComboBox
5.ComboBox selection event
6.Validate checkboxes/radios as a group
7.Ext.form.ComboBox selectOnFocus:true
8.typeAhead for Ext.form.ComboBox