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

dataSource.query

5 Answers 1299 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Anatoly
Top achievements
Rank 1
Anatoly asked on 11 Jan 2013, 09:22 AM
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?



5 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 11 Jan 2013, 06:03 PM
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!
0
Anatoly
Top achievements
Rank 1
answered on 11 Jan 2013, 07:52 PM
Thank you for your reply. 
I tried to use 
dataSource.query({ page: 1 });
but got the same error. 
0
Accepted
Alexander Valchev
Telerik team
answered on 15 Jan 2013, 02:20 PM
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!
0
Vladimir
Top achievements
Rank 1
answered on 15 Jan 2013, 02:28 PM
Thank you for your help. Now it works as expected
0
Anatoly
Top achievements
Rank 1
answered on 15 Jan 2013, 02:49 PM
Alexander, thank you
Tags
Data Source
Asked by
Anatoly
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Anatoly
Top achievements
Rank 1
Vladimir
Top achievements
Rank 1
Share this question
or