3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.onReady(function(){
10 var ds = new Ext.data.Store({
11 proxy: new Ext.data.ScriptTagProxy({
12 url: 'http://extjs.com/forum/topics-remote.php'
14 reader: new Ext.data.JsonReader({
16 totalProperty: 'totalCount',
19 {name: 'title', mapping: 'topic_title'},
20 {name: 'topicId', mapping: 'topic_id'},
21 {name: 'author', mapping: 'author'},
22 {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
23 {name: 'excerpt', mapping: 'post_text'}
27 // Custom rendering Template
28 var resultTpl = new Ext.XTemplate(
29 '<tpl for="."><div class="search-item">',
30 '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>{title}</h3>',
35 var search = new Ext.form.ComboBox({
39 loadingText: 'Searching...',
45 itemSelector: 'div.search-item',
46 onSelect: function(record){ // override default onSelect to do redirect
48 String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);