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

oData google-like filter

11 Answers 201 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 18 Oct 2011, 01:16 PM
With the Kendo DS and oData, is there a way to configure this so it searches all words not just an exact string?

Like if this is the text in the DB

"This is the string I want to find"

In the autocomplete I want to type
"string find" (without the quotes obviously)

Doable somehow??  I have it set to a contains filter already...

11 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 21 Oct 2011, 06:20 AM
Hello Steve,

 
The required functionality is a custom filtering, which should be performened on the server. You can turn on the serverFiltering to "true" and perform the custom filtering on the server and return the correctly filtered data.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 19 Dec 2011, 12:36 PM
I feel like this is wrong...I mean, oData can perform this exact operation in the uri out of the box, I shouldn't need any custom server filtering at all.

So this is what you do now:
$filter=substringof('wheat bread',AliasDesc)

This is what I want it to do though:
$filter=substringof('wheat',AliasDesc) and substringof('bread',AliasDesc)

I would expect it to search for "wheat bread" if I enclose it in quotes

Could you not add a new search "Type" which treats every word in the string as a new "substringof"?  So not just starts, ends, contains?
0
Georgi Krustev
Telerik team
answered on 22 Dec 2011, 11:07 AM
Hello,

Thank you for the feature request. If more users vote for it in the user-voice opened on the same matter we will schedule it for further investigation.


Regards,

Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 22 Dec 2011, 02:35 PM
Fair enough, :)

Has it even been discussed though georgi?...

For anyone reading this post, this is the uservoice link

http://kendo.uservoice.com/forums/127393-kendo-ui-feedback/suggestions/2464433-google-like-odata-autocomplete
0
Atanas Korchev
Telerik team
answered on 22 Dec 2011, 03:24 PM
Hi,

I confirm that this has been discussed internally. We decided to let the users vote for this feature request to determine what the demand is. This is how we handle all feature requests which are not trivial to implement.

Please have in mind that the feature set for the upcoming release has already been determined.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 27 Dec 2011, 03:04 AM
Ok, so since this wont be in anytime soon :)

I did what you suggested and made a custom filter method on the service

(fiddler this)
http://odata.gourmetsleuth.com/USDA.svc/FoodSearch?$format=json&searchterm='wheat%20germ'&take=10

However I'm a bit stumped how to convert the custom method to the KendoDS format

This is what I have so far (and it calls back, but the combo doesn't open)
_autoCompleteDS = new kendo.data.DataSource({
        type: "jsonp", //Specifies data protocol
        pageSize: 10, //Limits result set
        severFiltering: false,
        serverPaging: false,
        transport: {
            read: {
                url: "http://odata.gourmetsleuth.com/USDA.svc/FoodSearch?$format=json&$callback=callback&searchterm='wheat%20germ'",
                dataType: 'jsonp',
                cache: true,
                jsonp: false,
                jsonpCallback: 'callback'
            }
        }
    });

Seems that the DS configured to oData in my working version returns data.d.results, where this custom method returns data.d

So there's two problems
1) Unsure of proper structure
2) Unsure how to get the searched term from the combo into the "searchterm" var for the service.
0
Atanas Korchev
Telerik team
answered on 27 Dec 2011, 08:37 AM
Hello,

 Your method seems to return OData v1 whereas the Kendo DataSource needs OData v2. You can find more info in the OData JSON specification.

 You can use the data setting of the transport to send additional parameters:

 transport: {
     read: {
           data: function() {
                     return {
                           searchterm: $("#autocomplete").data("kendoAutoComplete").value()
                     }
           }
     }
 }

All the best,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 27 Dec 2011, 03:47 PM
Thats odd, I'm defining it as V2

config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;

So I assume then I need to decorate the method perhaps with something or return it in that format manually...I'll figure it out, thanks
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 27 Dec 2011, 04:21 PM
Ok, so couple things after playing with this for a while :)

1) There doesn't appear to be anything to decorate my service operation method with to have it return wrapped with V2, so I'm trying to do it as JSONP instead of type "odata"
_autoCompleteDS = new kendo.data.DataSource({
        type: "jsonp", //Specifies data protocol
        pageSize: 10, //Limits result set
        severFiltering: true,
        serverPaging: true,
        transport: {
            read: {
                url: "http://odata.gourmetsleuth.com/USDA.svc/FoodSearch?$format=json&$callback=callback",
                dataType: 'jsonp',
                cache: true,
                jsonp: false,
                jsonpCallback: 'callback',
                data: function () {
                    return {
                        searchterm: $("#food-box").data("kendoComboBox").text()
                    }
                }
            }
        }
    });


2) oData requires the string params to be wrapped in single quotes
data: function () {
                    return {
                        searchterm: "'" + $("#food-box").data("kendoComboBox").text() + "'"
                    }
                }

However doing that seems to force the DS to go insane and refresh itself over and over and over again (really fast)...cached...but still
0
Atanas Korchev
Telerik team
answered on 28 Dec 2011, 11:28 AM
Hi,

 I created an example showing how to implement filtering using OData (without relying on the built-in OData support). You can find it here.

 It turns out that jQuery will encode special symbols provided by the data setting of the transport (such as $ in $filter). I used parameterMap instead which is not mangled by jQuery.

I hope this helps,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 31 Dec 2011, 06:28 PM
Hey hey!  Seems to work well now, thanks so much, playing with the fiddle helped tons

http://jsfiddle.net/b4qre/10/
Tags
AutoComplete
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Georgi Krustev
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Atanas Korchev
Telerik team
Share this question
or