I have the following:
<telerik:RadComboBox ID="healthNumberCmbo" runat="server" AllowCustomText="true" |
HighlightTemplatedItems="true" EnableLoadOnDemand="true" LoadingMessage="Loading ..." Height="250px" |
MarkFirstMatch="true" OnClientItemsRequesting="onClientItemsRequesting" |
OnClientItemDataBound="onClientItemDataBound"> |
<WebServiceSettings Method="GetPatients" Path="Services/PatientAC.asmx" /> |
</telerik:RadComboBox> |
<!-- Client-side Data Template --> |
<div id="myTemplate" class="sys-template"> |
<b>Name: </b>{{FullName}}<br /> |
<b>DOB: </b>{{BirthDate.format("MM/dd/yyyy")}}<br /> |
<b>HC#: </b>{{HealthNumber}} |
</div> |
function onClientItemsRequesting(sender, eventArgs) |
{ |
var context = eventArgs.get_context(); |
context["filterString"] = eventArgs.get_text(); |
} |
function onClientItemDataBound(sender, eventArgs) |
{ |
var item = eventArgs.getItem(); |
var dataItem = eventArgs.get_dataItem(); |
// set the attributes that we can use when they select the item |
item.get_attributes().setAttribute("healthNumber", dataItem.HealthNumber); |
item.get_attributes().setAttribute("fullName", dataItem.FullName); |
item.get_attributes().setAttribute("birthDate", dataItem.BirthDate); |
// set the value to the ID of the patient |
item.set_value(dataItem.PatientID); |
var template = new Sys.UI.Template($get("myTemplate")); |
template.instantiateIn(item.get_element(), dataItem); |
} |
When the user clicks to open the combo box, and it loads, and they use the UP and DOWN arrows on the keyboard, the text that gets set in the combo box is what was in the template for that item.
How can I use the template, but at the same time - be able to only put the Health Number in the textbox. The reason is that we have clientside validation by using the CustomValidator - and for that to work before you select the item, the text in the box needs to be what i'm expecting.
Case 1: What I currently get in the textbox when the user uses the UP/DOWN keys and doesn't press enter or leave the combo ...
Name: Some Guy DOB: 1/1/2009 HC#: 1234567890
Case 2: What I want in the textbox under that situation:
1234567890
I'm using a validation RegEx of "^\\d{10}$", which obviously isn't valid under Case 1 ..
Help!