ComboBox AND Grid Combobox autocomplete (compressed)
No... I'm not uncompressing it. It's 4:05 and I've been up more days than I care... <grumble> This works with the default V2.01 with no modifications.
First, here's a regular combobox with the "onkeyup" handler calling the autoCompleteCombo function. <no sleep in 42 hours> Simple example, custom width on the popup to accomodate the long names in my Manufacturers_List_Arr array.
Second here's an example of a grid with a combobox template being used with the same thing. Again, pretty simple, <sleeping at keyboard> I just included the basics.
And now for the working autocomplete box... enjoy. It took me mucho hours. <snoring>
Cheers, John
First, here's a regular combobox with the "onkeyup" handler calling the autoCompleteCombo function. <no sleep in 42 hours> Simple example, custom width on the popup to accomodate the long names in my Manufacturers_List_Arr array.
var Input_ItemInfo_Manufacturer = new AW.UI.Combo;
Input_ItemInfo_Manufacturer.setId("Input_ItemInfo_Manufacturer");
Input_ItemInfo_Manufacturer.setEvent("onkeyup", autoCompleteCombo);
Input_ItemInfo_Manufacturer.setItemText(Manufacturers_List_Arr);
Input_ItemInfo_Manufacturer.setItemCount(Manufacturers_List_Arr.length);
Input_ItemInfo_Manufacturer.getPopupTemplate().setStyle("width","295px");
document.write(Input_ItemInfo_Manufacturer);
Second here's an example of a grid with a combobox template being used with the same thing. Again, pretty simple, <sleeping at keyboard> I just included the basics.
var BASE_UNITS_LIST = new AW.UI.List;
//BASE_UNITS_LIST_ARR is defined elsewhere, but it's a 1D array
BASE_UNITS_LIST.setItemText(BASE_UNITS_LIST_ARR);
BASE_UNITS_LIST.setItemCount(BASE_UNITS_LIST_ARR.length);
var Grid_Items_Items = new AW.UI.Grid;
Grid_Items_Items.setId("Grid_Items_Items");
Grid_Items_Items.setHeaderText(Headings_Items_Items);
Grid_Items_Items.setColumnCount(Headings_Items_Items.length);
Grid_Items_Items.setCellEditable(true);
Grid_Items_Items.setCellTemplate(new AW.Templates.Checkbox,11);
Grid_Items_Items.setHeaderTooltip("Taxable",11);
Grid_Items_Items.setCellTemplate(new AW.Templates.Combo,3);
Grid_Items_Items.getCellTemplate(3).setEvent("onkeyup",autoCompleteCombo);
Grid_Items_Items.setPopupTemplate(BASE_UNITS_LIST,3);
Grid_Items_Items.getPopupTemplate(3).setStyle("width", "40px");
And now for the working autocomplete box... enjoy. It took me mucho hours. <snoring>
function autoCompleteCombo(event){var key=String.fromCharCode(event.keyCode || event.charCode);switch (event.keyCode) {case 38:case 40:case 37:case 39:case 33:case 34:case 36:case 35:case 13:case 9:case 27:case 16:case 17:case 18:case 20:case 8:case 46:return;break;};var list;if(typeof(this.getItemCount)=='undefined'){list=this.getPopupTemplate();}else{list=this;}var tbox=this.getContent("box/text").element();var tboxValue=tbox.value;var i;var found=false;for(i=0;i<list.getItemCount();i++){if(list.getItemText(i).toUpperCase().indexOf(tboxValue.toUpperCase())==0){found=true;break;}}var iLen = tbox.value.length;if(found){tbox.value = list.getItemText(i);list.setCurrentItem(i);}else{tbox.value = '';}if(tbox.setSelectionRange) {tbox.setSelectionRange(iLen, tbox.value.length);} else {var oRange = tbox.createTextRange();oRange.moveStart("character", iLen);oRange.moveEnd("character", tbox.value.length-iLen);oRange.select();}return;};
Cheers, John
John Mason
December 8,