Below are the java scrip and code behind.
SInce we have a lot of data for the drop down box, we are not loading the drop down on the page load.
User will start typing the value and then we will return data to the control.
If i typed 56 in the drop down, no data is populating, if i backspace 6, then i do get data that starts with 56
If i type 5 nothing happend, if i typed 5 and backspaced then it is loading data
Can you please help?
function
OnVendorNameKeyPress(sender, eventArgs)
{
var a = eventArgs.get_domEvent().keyCode;
// 8 - Backspace
// 127 - Delete
if (a >= 32 && a <= 126 || a == 8 || a == 127)
{
var b = sender.get_text() ? sender.get_text() : '';
if (a >= 32 && a <= 126)
{
b += String.fromCharCode(a);
}
if (b && b != $$$._vendorNamePart)
{
$$$._vendorNamePart = b;
$$$._departmentReq =
false;
sender.requestItems(
'txt:' + b, false);
}
}
Protected
Sub ctlRComboBoxVendorID_ItemsRequested(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles ctlRComboBoxVendorID.ItemsRequested
If New DB_BLL.Cache().IsMaintain Then
e.Message =
""
Try
Dim comBox As RadComboBox = sender
If Not (comBox Is Nothing) Then
If Not (e.Text Is Nothing) And (e.Text.StartsWith("txt:") Or e.Text.StartsWith("id:")) Then
If e.Text.StartsWith("txt:") And e.Text.Length > 4 Then
Dim txt As String = e.Text.Substring(4)
Me.ctlRComboBoxVendorID.Items.Clear()
Dim vendorList As List(Of TMS402VH_VENDOR) = DB_VENDOR.GetAllVendorsByVendorNumber(txt)
If Not (vendorList Is Nothing) And vendorList.Count <> 0 Then
For Each info As TMS402VH_VENDOR In vendorList
Me.ctlRComboBoxVendorID.Items.Add(New RadComboBoxItem(info.VENDOR_ID.ToString() & " - " & info.VENDOR_NME.Trim(), info.VENDOR_ID))
Next
End If
ElseIf e.Text.StartsWith("id:") And e.Text.Length > 3 Then
Dim departmentId As Integer = 0
Try
departmentId = Convert.ToInt32(e.Text.Substring(3))
Catch ex As Exception
departmentId = 0
End Try
Me.ctlRComboBoxVendorID.Items.Clear()
Dim vendorList As List(Of TMS402VH_VENDOR) = DB_VENDOR.GetAllVendorsByDepartment(departmentId, String.Empty, False)
If Not (vendorList Is Nothing) And vendorList.Count <> 0 Then
For Each info As TMS402VH_VENDOR In vendorList
Me.ctlRComboBoxVendorID.Items.Add(New RadComboBoxItem(info.VENDOR_ID.ToString() & " - " & info.VENDOR_NME.Trim(), info.VENDOR_ID))
Next
End If
End If
End If
End If
Catch ex As Exception
e.Message = ex.Message
End Try
End If
End Sub