dataSource.query

6 posts, 1 answers
  1. Anatoly
    Anatoly avatar
    8 posts
    Member since:
    Mar 2012

    Posted 11 Jan 2013 Link to this post

    Hello

    I have next code:
    var dataSource;
    function newsListInit() {
        dataSource = new kendo.data.DataSource({
            pageSize: 12,
            serverPaging: true,
           // ... //
        });
     
        $("#newsList").kendoMobileListView({
            dataSource: dataSource,
            template: $("#newsList-template").text(),
            endlessScroll: true,
            scrollTreshold: 30
        });
    }
    I want to use dataSource var from another view and declared it in global scope. When I use the query method (like so):
    dataSource.query({take:12, skip:12});
    the AJAX call runs, but in console I get the error:
    1. Uncaught TypeError: Cannot read property '0' of undefined kendo.mobile.min.js:14
      1. f.extend.refreshkendo.mobile.min.js:14
      2. p.isFunction.fjquery.min.js:2
      3. Class.extend.triggerkendo.mobile.min.js:9
      4. j.extend._processkendo.mobile.min.js:11
      5. j.extend.successkendo.mobile.min.js:11
      6. p.isFunction.fjquery.min.js:2
      7. l.fireWithjquery.min.js:2
      8. c.onload.c.onreadystatechangejquery.min.js:2

    Does it possible to use  dataSource in this way and how to do it right?



  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2894 posts

    Posted 11 Jan 2013 Link to this post

    Hello Anatoly,

    According to the relevant documentation the available operations for query method are paging, sorting, filtering, grouping. Please request a page number - the dataSource will automatically calculate skip and take parameters.

    Kind regards,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Anatoly
    Anatoly avatar
    8 posts
    Member since:
    Mar 2012

    Posted 11 Jan 2013 Link to this post

    Thank you for your reply. 
    I tried to use 
    dataSource.query({ page: 1 });
    but got the same error. 
  4. Answer
    Alexander Valchev
    Admin
    Alexander Valchev avatar
    2894 posts

    Posted 15 Jan 2013 Link to this post

    Hi Anatoly,

    Thank you for the sample project.

    My previous answer was misleading for which I apologize. Indeed the error occurs because DataSource's groups are undefined - to get this working you should add empty group parameter to the query method.
    dataSource.query({ page: 1, group: [] });

    In this way if you wish you can to pass the skip and take parameters too.
    dataSource.query({ take: 12, skip: 12, group: [] });

    Another possible approach is to use the page method.
    dataSource.page(2);

    I hope this will help.

    Kind regards,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Vladimir
    Vladimir avatar
    4 posts
    Member since:
    Jan 2013

    Posted 15 Jan 2013 Link to this post

    Thank you for your help. Now it works as expected
  6. Anatoly
    Anatoly avatar
    8 posts
    Member since:
    Mar 2012

    Posted 15 Jan 2013 Link to this post

    Alexander, thank you
Back to Top