Jun 15, 2009, 1:09 PM
[CLOSED] Combobox Type Ahead Selection Question
I have a combobox I am using for a company search tool. I load it with some of the possible companies and allow type ahead so the user can select a company from the list and see their details. If the company is not found in the store/drop down list, I want the combo box to submit the characters typed into the box to a javascript function and then the system will do a search based on those characters.
This worked before the .8 update, but it seems that this little bug (and in my case a feature [Smile] ) was changed.
How can I get characters typed into the combo box, that don't match a value in the combobox, into a javascript function so I can use them?
This worked before the .8 update, but it seems that this little bug (and in my case a feature [Smile] ) was changed.
How can I get characters typed into the combo box, that don't match a value in the combobox, into a javascript function so I can use them?
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm4.aspx.vb" Inherits="HomePage.WebForm4" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">
<title>The Magazine Manager</title>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'load the navigation menu
If Not Page.IsPostBack Then
SetupStore()
End If
End Sub
Public Sub SetupStore()
Dim Names As Object() = New Object(4) {}
Dim i As Integer
For i = 0 To 4
Names(i) = New Object() {i, "Company" & i}
Next
StoreNames.DataSource = Names
StoreNames.DataBind()
End Sub
</script>
<script type="text/javascript">
var selectCustomer = function() {
var ID = cboSearch.getValue();
var customer = cboSearch.getText();
Ext.Msg.alert('Select', 'customer: ' + customer + ' - id: ' + ID);
//clear out the combo box for the next search
//cboSearch.setValue('')
if (ID == '') {
//nothing selected
} else if (isNaN(ID)) {
//no company name found that matches, do a search
} else {
//company name matched, open the company record
}
return false;
};
var searchCustomer = function() {
//var ID = cboSearch.getValue();
//var customer = cboSearch.getText();
//Ext.Msg.alert('Search', gsCustomersID);
Ext.Msg.alert('Search', '');
};
</script>
<style type="text/css">
.search-item {font: 11px tahoma; border: 1px solid #fff; color: #555;}
</style>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" InitScriptMode="Inline">
</ext:ScriptManager>
<ext:Store ID="StoreNames" runat="server">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="ID" Type="Int"/>
<ext:RecordField Name="Name" Type="String"/>
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
<ext:Panel runat="server" ID="Panel1" Title="Testing">
<Body>
<ext:ComboBox
ID="cboSearch"
runat="server"
StoreID="StoreNames"
DisplayField="Name"
ValueField="ID"
TypeAhead="true"
LoadingText="Searching..."
Width="150"
ListWidth="150"
HideTrigger="true"
MinChars="3"
FireSelectonload="false"
ItemSelector="div.search-item"
ForceSelection="false" >
<Template ID="Template1" runat="server">
<tpl for=".">
<div class="search-item">
{Name}
</tpl>
</Template>
<Listeners>
<Select Fn="selectCustomer" />
</Listeners>
</ext:ComboBox>
<ext:Button runat="server" ID="ButtonCustomerSearch" Text="" Icon="PlayBlue" Width="10">
<Listeners>
<Click Fn="selectCustomer" />
</Listeners>
</ext:Button>
</Body>
</ext:Panel>
</form>
</body>
</html>
p.s. I am actually getting the drop down values from a web service as in this example. For simplicity's sake, I just created the list in code, the values from the web service act the same way.