peterchenping
1 Jun 2007, 10:27 AM
I think ext team need to separa Combobox and Autocomplete feature to make thing simple. I played ext.form.combobox for a few days, I was never able to cache query data that come from the sever. YUI 2.2 already has this auto cache data feature, but through the adapter the thing has been change.
here is YUI cofiguration for autocomplete.
YAHOO.example.ACFlatData = function(){
var mylogger;
var oACDS;
var oAutoComp1;
return {
init: function() {
oACDS = new YAHOO.widget.DS_XHR("./php/ysearch_flat.php", ["\n", "\t"]);
oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
oACDS.maxCacheEntries = 100;
oACDS.queryMatchSubset = true;
// Instantiate second AutoComplete
oAutoComp1 = new YAHOO.widget.AutoComplete('ysearchinput1','ysearchcontainer1', oACDS);
oAutoComp1.delimChar = "";
oAutoComp1.useShadow = true;
oAutoComp1.formatResult = function(oResultItem, sQuery) {
var sKey = oResultItem[0];
var nQuantity = oResultItem[1];
var sKeyQuery = sKey.substr(0, sQuery.length);
var sKeyRemainder = sKey.substr(sQuery.length);
var aMarkup = ["<div class='ysearchresult'><div class='ysearchquery'>",
nQuantity,
"</div><span style='color:blue; font-weight: bold;'>",
sKeyQuery,
"</span>",
sKeyRemainder,
"</div>"];
return (aMarkup.join(""));
};
oAutoComp1.itemSelectEvent.subscribe(itemSelectHandler);
},
validateForm: function() {
// Validate form inputs here
return false;
}
};
}();
YAHOO.util.Event.addListener(this,'load',YAHOO.example.ACFlatData.init);
here is YUI cofiguration for autocomplete.
YAHOO.example.ACFlatData = function(){
var mylogger;
var oACDS;
var oAutoComp1;
return {
init: function() {
oACDS = new YAHOO.widget.DS_XHR("./php/ysearch_flat.php", ["\n", "\t"]);
oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
oACDS.maxCacheEntries = 100;
oACDS.queryMatchSubset = true;
// Instantiate second AutoComplete
oAutoComp1 = new YAHOO.widget.AutoComplete('ysearchinput1','ysearchcontainer1', oACDS);
oAutoComp1.delimChar = "";
oAutoComp1.useShadow = true;
oAutoComp1.formatResult = function(oResultItem, sQuery) {
var sKey = oResultItem[0];
var nQuantity = oResultItem[1];
var sKeyQuery = sKey.substr(0, sQuery.length);
var sKeyRemainder = sKey.substr(sQuery.length);
var aMarkup = ["<div class='ysearchresult'><div class='ysearchquery'>",
nQuantity,
"</div><span style='color:blue; font-weight: bold;'>",
sKeyQuery,
"</span>",
sKeyRemainder,
"</div>"];
return (aMarkup.join(""));
};
oAutoComp1.itemSelectEvent.subscribe(itemSelectHandler);
},
validateForm: function() {
// Validate form inputs here
return false;
}
};
}();
YAHOO.util.Event.addListener(this,'load',YAHOO.example.ACFlatData.init);