Two hiccups with AutoCompleteBox in grid

5 posts, 1 answers
  1. Chris
    Chris avatar
    6 posts
    Member since:
    Jan 2015

    Posted 20 Jan 2015 Link to this post

    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 use "<%#DataBinder.Eval(Container.DataItem, "PartNumber")%>" in the EditItemTemplate to get the text to show up under/over the 'Box 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!
  2. Chris
    Chris avatar
    6 posts
    Member since:
    Jan 2015

    Posted 20 Jan 2015 Link to this post

    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 tiny-bit wrong when converting from C#.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 23 Jan 2015 Link to this post

    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.

     
  5. Chris
    Chris avatar
    6 posts
    Member since:
    Jan 2015

    Posted 27 Jan 2015 in reply to Nencho Link to this post

    Anyone reading this in the future -- Nencho 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 box's .Text property, go to .Entries(0).Text
  6. Answer
    Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 29 Jan 2015 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017