52,797
社区成员
发帖
与我相关
我的任务
分享
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);
}
});
{"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":"傅王宾"}]}