source: trunk/web/addons/job_monarch/lib/extjs/examples/form/forum-search.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 1.6 KB
RevLine 
[619]1/*
2 * Ext JS Library 2.2.1
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9Ext.onReady(function(){
10
11    var ds = new Ext.data.Store({
12        proxy: new Ext.data.ScriptTagProxy({
13            url: 'http://extjs.com/forum/topics-remote.php'
14        }),
15        reader: new Ext.data.JsonReader({
16            root: 'topics',
17            totalProperty: 'totalCount',
18            id: 'post_id'
19        }, [
20            {name: 'title', mapping: 'topic_title'},
21            {name: 'topicId', mapping: 'topic_id'},
22            {name: 'author', mapping: 'author'},
23            {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
24            {name: 'excerpt', mapping: 'post_text'}
25        ])
26    });
27
28    // Custom rendering Template
29    var resultTpl = new Ext.XTemplate(
30        '<tpl for="."><div class="search-item">',
31            '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>{title}</h3>',
32            '{excerpt}',
33        '</div></tpl>'
34    );
35   
36    var search = new Ext.form.ComboBox({
37        store: ds,
38        displayField:'title',
39        typeAhead: false,
40        loadingText: 'Searching...',
41        width: 570,
42        pageSize:10,
43        hideTrigger:true,
44        tpl: resultTpl,
45        applyTo: 'search',
46        itemSelector: 'div.search-item',
47        onSelect: function(record){ // override default onSelect to do redirect
48            window.location =
49                String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);
50        }
51    });
52});
Note: See TracBrowser for help on using the repository browser.