EXT ComboBox - Live Search

ch19851818 2013-07-23 07:17:29
各位大侠,我实现ComboBox - Live Search时,JSON数据都能得到,就是无法匹配,请问下是怎么回事:
JS:
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'test.do?reqCode=list'
}),
reader: new Ext.data.JsonReader({
root: 'ROOT',
totalProperty: 'TOTALCOUNT',
id: 'studentname'
}, [
{name: 'studentname', mapping: 'studentname'}
])
});
// Custom rendering Template
var resultTpl = new Ext.XTemplate(
'<tpl for="."><div class="search-item">',
'<h3>{studentname}</h3>',
'</div></tpl>'
);

var search = new Ext.form.ComboBox({
store: ds,
minChars:2,
displayField:'studentname',
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
alert(record.data.topicId);
search.setValue(record.data.topicId);
// window.location =String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);
}
});

JSON:
{"TOTALCOUNT":10, "ROOT":[{"rn":1,"studentcode":"xy00000002","studentname":"123456"},{"rn":2,"studentcode":"xy00000003","studentname":"66666"},

{"rn":3,"studentcode":"xy00000004","studentname":"4545"},{"rn":4,"studentcode":"xy00034753","studentname":"沈小苹"},{"rn":5,"studentcode":"xy00037999","studentname":"朱文保"},

{"rn":6,"studentcode":"xy00039017","studentname":"陈昊"},{"rn":7,"studentcode":"xy00039123","studentname":"胡凤娣"},{"rn":8,"studentcode":"xy00039163","studentname":"朱能尚"},

{"rn":9,"studentcode":"xy00039245","studentname":"王冰"},{"rn":10,"studentcode":"xy00039769","studentname":"傅王宾"}]}
...全文
248 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Go 旅城通票 2013-07-24
  • 打赏
  • 举报
回复
你的是remote加载的,每次都会从服务器下载数据,你的test.do?reqCode=list需要通过ext传递的关键字进行过滤然后返回需要的数据 如果不想每次都从服务器加载,设置store自动加载,combox的mode: 'local', var ds = new Ext.data.Store({ autoLoad: true, var search = new Ext.form.ComboBox({ store: ds, mode: 'local',

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧