This is a migrated thread and some comments may be shown as answers.

Two hiccups with AutoCompleteBox in grid

4 Answers 97 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 20 Jan 2015, 04:35 PM
Hi, I'm having two issues and I suspect at least one of them is dead-simple and caused by me making a simple mistake with me AutoCompleteBox in the EditItemTemplate of a GridTemplateColumn.

First problem; When I enter edit mode for a grid row, the AutoCompleteBox is empty rather than displaying the value that showed in that column before it entered edit mode. (I can "<%#DataBinder.Eval(Container.DataItem, "PartNumber")%>" in the EditItemTemplate to get the text to show up under/over the but that's not a solution.

Second problem; The AutoCompleteBox (set to single selection mode and text input) was appending a semicolon to the selected value. So I tried setting Delimiter="" which got rid of the unwanted character, but then it messed up the auto-complete functionality. Once that change was made, the drop-down options would appear if I paste a string into the box all at once, but not ever if I just typed the same string in. So, either: what's the right way to eliminate the semicolon, or how do I make the autocomplete function work right with delimiter set to an empty string? (I could theoretically trim the semicolon when I'm setting the value of the parameter before updating the DB, but that's a terrible solution since I might theoretically want semicolons in the PartNumber at some future date.)

                        <telerik:GridTemplateColumn UniqueName="PartNumber" HeaderText="Part Number" ItemStyle-CssClass="editWidth" 
                                FilterControlAltText="Filter PartNumber column" FilterControlWidth="85%">
                            <ItemTemplate><%#DataBinder.Eval(Container.DataItem, "PartNumber")%></ItemTemplate>
                            <EditItemTemplate>
                                <telerik:RadAutoCompleteBox runat="server" ID="racbPN" DataSourceID="ItemIdSource" DataTextField="IMA_ItemID" 
                                    HighlightFirstMatch="true" InputType="Text" TextSettings-SelectionMode="Single" MaxResultCount="200" MinFilterLength="4" 
                                     Delimiter="" DropDownHeight="300px" DropDownWidth="200px">
                                </telerik:RadAutoCompleteBox>
                            </EditItemTemplate>
                            <HeaderStyle Width="190px"></HeaderStyle>
                        </telerik:GridTemplateColumn>

Thanks for your time!

4 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 20 Jan 2015, 08:09 PM
Regarding my first problem, I saw in another thread the suggestion to add the following code to the RadGrid's ItemDataBound event:

            If e.Item.IsInEditMode Then
                Dim item As GridEditableItem = e.Item
                If Not e.Item Is GetType(IGridInsertItem) Then
                    Dim auto As RadAutoCompleteBox = CType(item.FindControl("racbPN"), RadAutoCompleteBox)
                    auto.Entries.Add(New AutoCompleteBoxEntry(item("PartNumber").Text))
                End If
            End If

But when that code runs, the item("PartNumber").Text is blank so that doesn't seem to be an option unless I just got something a wrong when converting from C#.
0
Nencho
Telerik team
answered on 23 Jan 2015, 12:05 PM
Hello Chirs,

Regarding the data binding issue that you have encountered - you need to access the field from the DataItem of the currently evaluated item in the ItemDataBoundHandler. Please consider the following implementation :

Dim PartNumber As String = DirectCast(e.Item.DataItem, DataRowView)("PartNumber").ToString()
Dim auto As RadAutoCompleteBox = DirectCast(item.FindControl("AutoCompleteBox1"), RadAutoCompleteBox)
auto.Entries.Add(New AutoCompleteBoxEntry(PartNumber))

As for your other question, by design if the selection mode is set to single, the RadAutoCompleteBox should not append the semi column at the end of the newly added entry. Could you please specify the version of our controls that you are currently using? In addition, here is a video, demonstrating the behavior at my end :

http://screencast.com/t/43785vzqO3

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Chris
Top achievements
Rank 1
answered on 27 Jan 2015, 04:55 PM
Anyone reading this in the future -- and I worked through my problems in a trouble ticket.

1) The data-display solution worked perfectly.

2) Don't set delimiter="", but when accessing the value of the AutoCompleteBox, to avoid the semicolon, don't use the Text property, go Entries(0).Text
0
Accepted
Nencho
Telerik team
answered on 29 Jan 2015, 11:53 AM
Hello,

Thank you, Chris, for sharing the information with the community. Indeed the currently the Text property of the RadAutoCompleteBox (in single selection mode) will return the text with appended semi-column at the end. This will be fixed as soon as possible, as for now, you can use the only Entry's text property as Chris demonstrated above.

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
AutoCompleteBox
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or