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 | |
---|
9 | 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' |
---|
13 | }), |
---|
14 | reader: new Ext.data.JsonReader({ |
---|
15 | root: 'topics', |
---|
16 | totalProperty: 'totalCount', |
---|
17 | id: 'post_id' |
---|
18 | }, [ |
---|
19 | {name: 'postId', mapping: 'post_id'}, |
---|
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 | baseParams: {limit:20, forumId: 4} |
---|
28 | }); |
---|
29 | |
---|
30 | // Custom rendering Template for the View |
---|
31 | var resultTpl = new Ext.XTemplate( |
---|
32 | '<tpl for=".">', |
---|
33 | '<div class="search-item">', |
---|
34 | '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>', |
---|
35 | '<a href="http://extjs.com/forum/showthread.php?t={topicId}&p={postId}" target="_blank">{title}</a></h3>', |
---|
36 | '<p>{excerpt}</p>', |
---|
37 | '</div></tpl>' |
---|
38 | ); |
---|
39 | |
---|
40 | var panel = new Ext.Panel({ |
---|
41 | applyTo: 'search-panel', |
---|
42 | title:'Forum Search', |
---|
43 | height:300, |
---|
44 | autoScroll:true, |
---|
45 | |
---|
46 | items: new Ext.DataView({ |
---|
47 | tpl: resultTpl, |
---|
48 | store: ds, |
---|
49 | itemSelector: 'div.search-item' |
---|
50 | }), |
---|
51 | |
---|
52 | tbar: [ |
---|
53 | 'Search: ', ' ', |
---|
54 | new Ext.app.SearchField({ |
---|
55 | store: ds, |
---|
56 | width:320 |
---|
57 | }) |
---|
58 | ], |
---|
59 | |
---|
60 | bbar: new Ext.PagingToolbar({ |
---|
61 | store: ds, |
---|
62 | pageSize: 20, |
---|
63 | displayInfo: true, |
---|
64 | displayMsg: 'Topics {0} - {1} of {2}', |
---|
65 | emptyMsg: "No topics to display" |
---|
66 | }) |
---|
67 | }); |
---|
68 | |
---|
69 | ds.load({params:{start:0, limit:20, forumId: 4}}); |
---|
70 | }); |
---|