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

Modify the search query on the AutocompleteBox

9 Answers 254 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Olivier
Top achievements
Rank 2
Olivier asked on 12 Nov 2012, 09:20 AM
Hello,

In the autocompletBox , we search in the "DataTextField" which represent the column,

is it possible to take the query and modify this, to search on the other column ?


I want to search in City table, i must to search Zip code or City Name in the same AutocompleteBox.

Please
Have you a solution ?

thanks
Olivier,


9 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 12 Nov 2012, 04:13 PM
Hello olivier,

In general modifying the search query of the RadAutoCompleteBox is not a supported scenario.

How do you populate the RadAutoCompleteBox with data?
Could you please paste here some code to illustrate your implementation?

Regards,
Kalina
the Telerik team
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.
0
Olivier
Top achievements
Rank 2
answered on 12 Nov 2012, 05:01 PM
Hello

I populate with Strataframe Business Object similar to  RadODataDataSource

If i have name and last name ?

john smith
eddy white

i want to search "john" or "eddy" or "smith" or "white"

I make in my query  : select name+' '+lastname from MyTable , but my filter StartWidth and i don't search on "smith" or "White".

in french :
Cp   = Zip Code
ville =  City Name

I want to search on this Column

 <SFWeb:WebBusinessBindingSource runat="server" ID="WbAffaires" BusinessObjectName="oAffairesBo"></SFWeb:WebBusinessBindingSource>
                            <telerik:RadAutoCompleteBox runat="server" ID="RadAutoCompleteBox1" Width="340" DataSourceID="WbAffaires" Filter="StartsWith" CssClass="RadAutoCompleteBox_Default"
                            DropDownWidth="300px" DataTextField="ville" DataValueField="cp" InputType="Token" Delimiter="," EmptyMessage="Ville, CP ou département." AllowCustomEntry="False">
                            </telerik:RadAutoCompleteBox>


thanks
Olivier,
0
Kalina
Telerik team
answered on 12 Nov 2012, 05:13 PM
Hi olivier,

I am afraid that databining the RadAutoCompleteBox via Stataframe Business Object is not a supported scenario.

Regards,
Kalina
the Telerik team
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.
0
Olivier
Top achievements
Rank 2
answered on 12 Nov 2012, 05:24 PM
it's not a problem cause it's work,

Have you a sample with other datasource to search a value in two or third column ?

And do you confirm me , with the datasource of your choice, that we can search in other column  of the datasource ?

thanks
Olivier,

0
Princy
Top achievements
Rank 2
answered on 14 Nov 2012, 07:44 AM
Hi Olivier,

You can search the value in two columns in a table using SqlDataSource as follows.

ASPX:
<asp:SqlDataSource ID="SqlDataSource1" runat ="server" ConnectionString ="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT City AS data FROM Customers UNION SELECT ZipCode AS data FROM Customers">
</asp:SqlDataSource>
<telerik:RadAutoCompleteBox runat="server" ID="RadAutoCompleteBox1"  DataSourceID="SqlDataSource1" DataTextField="data" AutoPostBack="true" Filter="StartsWith">
</telerik:RadAutoCompleteBox >

Hope this helps.

Thanks,
Princy.
0
Olivier
Top achievements
Rank 2
answered on 14 Nov 2012, 08:16 AM
Hello Princy

Great idea, why i don't think about this way.
it's simple and i can implement with Strataframe Business Object so.

Thanks You very much.
Olivier,
0
Olivier
Top achievements
Rank 2
answered on 14 Nov 2012, 08:44 AM
Princy,

Excuse me , but your solution it's a good way,

In the Autocomplete , i want to display the concatenation between the city and zip code.

Example :
___________________________________________________
| Display  in the Autocomplete     |      search in the union query   |
| Los Angeles (90001)                 |      Los Angeles or 90001        |
| Paris (75001)                             |      Paris or 75001                  |
----------------------------------------------------------------------------------

If you have Idea.
Olivier,
0
Princy
Top achievements
Rank 2
answered on 15 Nov 2012, 04:08 AM
Hi Olivier,

Try Modifying your code as follows to achieve your scenario.

ASPX:
<asp:SqlDataSource ID="SqlDataSource3" runat ="server" ConnectionString ="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT City+' ('+PostalCode+')' AS data FROM Customers">
</asp:SqlDataSource>
<telerik:RadAutoCompleteBox runat="server" ID="RadAutoCompleteBox1"  DataSourceID="SqlDataSource3" DataTextField="data" AutoPostBack="true" Filter="Contains">
</telerik:RadAutoCompleteBox >

Hope this helps.

Thanks,
Princy.
0
Olivier
Top achievements
Rank 2
answered on 15 Nov 2012, 10:02 AM
Thanks Princy

it's definitively so bad, cause i must to have Filter "StartsWith" not "Contains"

May be telerik will add functionnality in the future.

http://www.telerik.com/community/forums/aspnet-ajax/autocompletebox/add-functionnality-autocompletebox-search-in-multi-column.aspx

Thanks for all,
Olivier
Tags
AutoCompleteBox
Asked by
Olivier
Top achievements
Rank 2
Answers by
Kalina
Telerik team
Olivier
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or