Prevent Searching Radcombobox Templates in Autocomplete

3 posts, 0 answers
  1. Mark Meikle
    Mark Meikle avatar
    16 posts
    Member since:
    Mar 2010

    Posted 21 May 2013 Link to this post

    I recently upgraded to 2013 controls from 2010. I have a radcombobox with template content. Previously, if I typed in the search box, it would search company name only. But now it searches all text, even that in the itemtemplate (such as address etc.). It is now slower, and searches text that I am not interested in searching. Can you please tell me how to search only the DataTextField and not the itemTemplate content? Thanks in advance.

    <telerik:RadComboBox ID="RadComboBoxGoThroughPublisher" Runat="server"
                                                AllowCustomText="True" AutoPostBack="False" CollapseDelay="0"
                                                DataSourceID="DataSourceAllPublishers" DataTextField="Company"
                                                DataValueField="PublisherID" EnableItemCaching="True" ExpandDelay="0"
                                                Filter="Contains" HighlightTemplatedItems="True" MarkFirstMatch="True"
                                                MaxHeight="300px"
                                                SelectedValue='<%# myHelperObject.helperGetLicenseThroughPublisherID(Eval("LicenseThroughPublisherID")) %>'
                                                TabIndex="8" Width="340px">
                                                <ItemTemplate>
                                                    <span>
                                                    <hr />
                                                    </span>
                                                    <asp:Label ID="LabelCompanyShort" runat="server" CssClass="blueHyperlink"
                                                        Text='<%# Eval("CompanyShort") %>'></asp:Label>
                                                    <br />
                                                    <span>
                                                    <asp:Label ID="LabelCompany" runat="server" CssClass="blueHyperlink"
                                                        Text='<%# Eval("Company") %>'></asp:Label>
                                                    </span>
                                                    <br />
                                                    <span>
                                                    <asp:Label ID="lblAddress" runat="server" Text='<%# Eval("Address") %>'></asp:Label>
                                                    <br />
                                                    <asp:Label ID="lblCityStateZip" runat="server"
                                                        Text='<%# myHelperObject.helperGetFormattedCityStateZip(Eval("City"),Eval("State"),Eval("ZipCode"),1,1,0) %>'></asp:Label>
                                                    <asp:Panel ID="PanelPartner" runat="server"
                                                        Visible='<%# myHelperObject.helperGetCheckBoxTrueFalse(Eval("Active")) %>'>
                                                        <div style="padding: 3px">
                                                            <span>
                                                            <asp:Label ID="LabelPartner" runat="server" CssClass="mediumBoldDarkAquaHeader"
                                                                Text="Partner"
                                                                Visible='<%# myHelperObject.helperGetCheckBoxTrueFalse(Eval("Active")) %>'></asp:Label>
                                                             <asp:Label ID="LabelPartnerSynch" runat="server"
                                                                CssClass="mediumBoldDarkAquaHeader" Text="- Synch Allowed"
                                                                Visible='<%# myHelperObject.helperGetCheckBoxTrueFalse(Eval("SynchronizationAllowed")) %>'></asp:Label>
                                                            </span>
                                                        </div>
                                                    </asp:Panel>
                                                    </span>
                                                </ItemTemplate>
                                            </telerik:RadComboBox>
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 24 May 2013 Link to this post

    Hello,

    I would like to clarify the RadComboBox filtering ( searching) functionality works for the text values of the items. Here you may watch a video that shows our online MultiColumn RadComboBox demo with the latest official RadControls release version ( 2013.1.417). It filters only by the text values of the items - in this case that is the contact name. When you try to filter by city name - for sample purposes "Berlin" - it returns zero results. 


    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Mark Meikle
    Mark Meikle avatar
    16 posts
    Member since:
    Mar 2010

    Posted 28 May 2013 Link to this post

    I received the following solution from Telerik in my support ticket. Posting it here for reference. The solution is to put this javascript at the bottom of the .aspx page containing the radcombobox you want to affect:

    <script type="text/javascript">
        Telerik.Web.UI.RadComboBoxItem.prototype._highlight = function (regex, element) {
            var item = this,
                matchIsFound = false;
                text = item.get_text();
      
            if (regex.test(text))
                matchIsFound = true;
      
            return matchIsFound;
        }
    </script>
Back to Top