oData Filter - How To

6 posts, 0 answers
  1. Don
    Don avatar
    38 posts
    Member since:
    Oct 2006

    Posted 20 Jul 2012 Link to this post

    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
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 23 Jul 2012 Link to this post

    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!
  3. Don
    Don avatar
    38 posts
    Member since:
    Oct 2006

    Posted 23 Jul 2012 Link to this post

    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" }        
                                  })
                       })
                };
  4. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 26 Jul 2012 Link to this post

    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!
  5. Don
    Don avatar
    38 posts
    Member since:
    Oct 2006

    Posted 26 Jul 2012 Link to this post

    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
  6. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 30 Jul 2012 Link to this post

    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!
Back to Top