I am using AutoCompleteBox to help user search various data. Now, the data shown to the user might not exactly correspond to what is written in table field. As I saw that AutoCompleteBoxItemData has Text and Value field, I have filled both accordingly, so that I would know what was their search term.
Traversing thorugh AutoCompleteBox.Entries however shows, that AutoCompleteBoxEntry has Value property set to string.Empty, no matter what I inserted in AutoCompleteBoxItemData Value property. Wouldn't it be nice to get Value property of an entry as well? Specially when I set it.
My markup:
<telerik:RadAutoCompleteBox ID="tbSearch" runat="server" InputType="Text" > <WebServiceSettings Method="EventSearch" Path="~/services/SearchService.asmx" /> </telerik:RadAutoCompleteBox> <telerik:RadButton ID="btnSearch" runat="server" Text="<%$ Resources:Global,Search %>" OnClick="btnSearch_Click"></telerik:RadButton><br />
My code behind:
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) For Each entry As AutoCompleteBoxEntry In tbSearch.Entries Dim strValue As String = Nothing strValue = entry.Value 'value = string.Empty Next End Sub
Part of web-service that fills the data:
Private Function GetDataResultFromSearchIndex(ByVal htIndex As Hashtable) As AutoCompleteBoxData Dim acdataResult As AutoCompleteBoxData = Nothing Dim lstitemAutoComplete As List(Of AutoCompleteBoxItemData) = Nothing acdataResult = New AutoCompleteBoxData() lstitemAutoComplete = New List(Of AutoCompleteBoxItemData)() For Each de As DictionaryEntry In htIndex Dim itemAutoComplete As AutoCompleteBoxItemData = Nothing itemAutoComplete = New AutoCompleteBoxItemData() itemAutoComplete.Text = GetKeyValue(de) itemAutoComplete.Value = GetResultValue(de) 'value is filled Call lstitemAutoComplete.Add(itemAutoComplete) Next acdataResult.Items = lstitemAutoComplete.ToArray() Return acdataResult End Function
13 Answers, 1 is accepted
I can't seem to reproduce the issue. I've attached the sample page I used to test the scenario. Could you verify whether the problem occurs on this page.
Regards,
Bozhidar
the Telerik team
Thing is though, that field must look like search. And I cannot use tokens.
By default when you use InputType="Text" the RadAutoCompleteBox renders just an input field that you can edit freely. Since we cannot keep track of how you edit the text already entered in the AutoCompleteBox, we currently do not support the Value property in this mode.
However in our latest internal build ( which was released today ) we have introduced a new rendering for the case where you have InputType="Text" and AllowCustomEntry="false" ( renamed from AllowCustomToken, so that in now works with both input types ). With this configuration of RadAutoCompleteBox the Value property is preserved and this issue is resolved.
Kind regards,
Bozhidar
the Telerik team
t_value.AllowCustomEntry = True
t_value.InputType = Token {0}
when I debug this I see:
?request("Qry$RBLK$LN_7ec03$t_value") = ""
?request("Qry_RBLK_LN_7ec03_t_value_ClientState") =
"{"enabled":true,"logEntries":[{"Type":1,"Index":0,"Data":{"text":"A. Brooke","value":"A. Brooke"}}],"delimiters":[]}"
It seem that the text entered (A. Brooke) does show in the data part of the client state. so why are are there no entries and the value is ""
Can you tell me if there is a way for the RadAutoComplete to preserve both text and value with the settings InputType="Text" and AllowCustomEntry="True"?
I am running version 2013.3.1114 with these settings and value is not preserved. If I set AllowCustomEntry="False" the value is preserved, but then I cannot enter a custom value.
With these settings it's not possible for the RadAutoCompleteBox to preserve the value of an entry.
Regards,
Bozhidar
Telerik
I have the same problem, I am using the radAutocomplete in inputmode Text and allow custom entry.
I should be great if itemData will be keep in this mode and set to empty only for cutoms entries not in the list.
Did you plan to do it in a further version of Telerik ?
Is there a workarround to use itemData in inputMode=Text and AllowCustomEntry=true ?
For the reasons mentioned below we still don't have a solution to store the value property of the AutoCompleteBox items when in Text mode with AllowCustomEntry true, that we find suitable for all scenarios. All solutions we've come up with thus far work only in limited scenarios, and can be easily broken. There is no way to reliably track the entries inside the textbox, when it's just plain text and can be edited freely, in order to preserve any additional information about them.
Please excuse us for the inconvenience caused.
Regards,
Bozhidar
Telerik
have to agree with Jasper...this control is no-longer usable for us.
We are using it to enter in email addresses, but also allowing the user to pick from a list already in the system.
so i have to have AllowCustomEntry =true. however i want the "text" look not the token.
hope your team finds a solution
I have run into this issue as well and have been using the following workaround.
Using the following settings:
AllowCustomEntry=true
InputType=Text
TextSettings-SelectionMode=Single
Withing the DropDownItemTemplate I put a javascript onclick event that calls a method to populate hidden fields.
ASPX:
1.
<
DropDownItemTemplate
>
2.
<
table
onclick
=
"RadAutoCompleteBox_StoreData('<%# DataBinder.Eval(Container.DataItem, "
RecordID")%>','<%# DataBinder.Eval(Container.DataItem, "RecordText")%>');">
3.
<!-- DropDownItemTemplate Text -->
4.
</
table
>
5.
</
DropDownItemTemplate
>
Javascript:
function
RadAutoCompleteBox_StoreData(value, text) {
var
SelectedText = text;
var
SelectedValue = value;
// populate the hidden fields based on the values sent from the list item
$(
"#hf_SelectedText"
).val(SelectedText);
// store the data text
$(
"#hf_SelectedValue"
).val(SelectedValue);
// store the data value
$(
"#hf_ListItemFound"
).val(
"1"
);
// indicate a list item was found
}
function
RadAutoCompleteBox_TextChanged(sender, eventArgs) {
// do a quick check to see if a list item was found
if
($(
"#hf_ListItemFound"
).val() ==
"1"
) {
$(
"#hf_ListItemFound"
).val(
"0"
);
// reset the list item found
}
else
{
// populate the hidden fields based on the text entered
$(
"#hf_SelectedText"
).val(eventArgs.get_text());
// use the textbox value
$(
"#hf_SelectedValue"
).val(
"0"
);
// set a default value
$(
"#hf_ListItemFound"
).val(
"0"
);
// reset the list item found
}
}
When the form is submitted, I just pulled the needed data from the hidden field. I populated the Text in a hidden field to keep it transparent. Typically, I just pull the text from the RadAutoCompleteBox.Text.
Hi! any news about this issue?
I agree that the control becomes useless since its impossible to retrieve the value when AllowCustomEntry =true
Thanks
Alejandro