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

oData Filter - How To

5 Answers 936 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Don
Top achievements
Rank 2
Don asked on 21 Jul 2012, 02:25 AM
what is the syntax to create this (wcf) oData query as a KendoDataSource.Transport:
var URL = DataServiceURL + "Customers()?$filter=startswith(CustomerName, '" + searchValue + "') eq true";
Thanks

5 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 23 Jul 2012, 06:53 AM
Hello Don,

Using DataSource filter API will generate the correct filter expression for OData services. If you build them manually here is the corresponding URI convention for OData v2 http://www.odata.org/documentation/uri-conventions#FilterSystemQueryOption

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Don
Top achievements
Rank 2
answered on 23 Jul 2012, 07:44 PM
How would this work with AutoComplete since the value must be provided in the filter:

HTML
    <div data-role="view" id="home" data-title="my AutoComplete">
            <div class="Container">
                <input id="searchInput"   data-role="autocomplete" />
            </div>
   </div>

JAVASCRIPT
           
            $(function() { 
                   $("#searchInput").kendoAutoComplete({
                              minLength:1,
                              dataTextField:'CustomerName',
                              dataSource: new kendo.data.DataSource({
                                  type:'GET',
                                  dataType:'odata',
                                  transport:{
                                      read: DataServiceURL + "Customers"
                                  },     
                                  filters: { field: "CustomerName", operator: "startswith", value: "X" }        
                              })
                   })
            };
0
Nikolay Rusev
Telerik team
answered on 26 Jul 2012, 09:31 AM
Hello Don,

The AutoComplete widget will automatically request the DataSource with startswith filter applied.

Greetings,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Don
Top achievements
Rank 2
answered on 26 Jul 2012, 06:47 PM
I just cant seem to get any data back period.
I have yet to successfully pull any data using the Kendo transport object.

perhaps you could help with this and point out the error of my ways.
Here is a jsFidlle that attempts to populate a (data) grid using oData feed.
link is: http://jsfiddle.net/theDon911/X8CFk/

any help would be truely appreciated.
I will continue to scour the forums.

Thanks-
Don
0
Nikolay Rusev
Telerik team
answered on 30 Jul 2012, 12:07 PM
Hello Don,

In case of OData binding you do not need to set dataType to read setting, but rather set type: "odata" as first level option of the DataSource. As in the fiddle: http://jsfiddle.net/Q4txb/

Secondly requesting the service returns returns an server error. One of the reasons might be if the service uses OData version 1 which doesn't have support for '$' parameters. You can find runnable example of using OData on the following code library: https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-odata-crud

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Don
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
Don
Top achievements
Rank 2
Share this question
or