是不是因为看到那个好看呀?:)
在2.0+ 的时候这个组件是一个ux组件,是用户扩展的.
现在3.0中要实现,简直就是太简单了
[code="js"]
var store = new Ext.data.Store({
url: 'getData.action',//查询框会调用这个对象的方法,然后根据这个url来访问服务器获得数据.后台你可以用任何语言都可以.没有限制的.
reader: new Ext.data.JsonReader({totalProperty: 'totalProperty',root: 'root'},
[
{name: 'pid'},
{name: 'a'},
{name: 'b'},
{name: 'c'}
])
});
//-----------------------
new Ext.form.TwinTriggerField({
validationEvent: false,
validateOnBlur: false,
trigger1Class: 'x-form-clear-trigger',
trigger2Class: 'x-form-search-trigger',
hideTrigger1: true,
width: 180,
hasSearch: false,
listeners: {
'specialkey': function(f, e) {
if (e.getKey() == e.ENTER) {
this.onTrigger2Click();
}
if (e.getKey() == e.ESC) {
this.hasSearch = true;
this.onTrigger1Click();
}
}
},
onTrigger1Click: function() {
if (this.hasSearch) {
this.el.dom.value = '';
this.triggers[0].hide();
this.hasSearch = false;
this.focus();
}
},
onTrigger2Click: function() {
var field = this.previousSibling().previousSibling().getValue();
var v = this.getRawValue();
//其实就是这一句啦.他调用了store的加载方法,具体数据怎么和后台也很简单呀.
store.reload({
params: {
value: v,
field: field,
start: 0,
limit: 20
}
});
this.hasSearch = true;
this.triggers[0].show();
this.focus();
}
})
[/code]