forum-search.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:2k
源码类别:
JavaScript
开发平台:
JavaScript
- /*!
- * Ext JS Library 3.1.0
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
- Ext.onReady(function(){
- var ds = new Ext.data.Store({
- proxy: new Ext.data.ScriptTagProxy({
- url: 'http://extjs.com/forum/topics-remote.php'
- }),
- reader: new Ext.data.JsonReader({
- 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>',
- '{excerpt}',
- '</div></tpl>'
- );
- var search = new Ext.form.ComboBox({
- store: ds,
- displayField:'title',
- typeAhead: false,
- loadingText: 'Searching...',
- width: 570,
- pageSize:10,
- hideTrigger:true,
- tpl: resultTpl,
- applyTo: 'search',
- itemSelector: 'div.search-item',
- onSelect: function(record){ // override default onSelect to do redirect
- window.location =
- String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);
- }
- });
- });