Hello
I have next code:
I want to use dataSource var from another view and declared it in global scope. When I use the query method (like so):
the AJAX call runs, but in console I get the error:
Does it possible to use dataSource in this way and how to do it right?
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
});
}
dataSource.query({take:12, skip:12});
- Uncaught TypeError: Cannot read property '0' of undefined kendo.mobile.min.js:14
-
f.extend.refreshkendo.mobile.min.js:14
-
p.isFunction.fjquery.min.js:2
-
Class.extend.triggerkendo.mobile.min.js:9
-
j.extend._processkendo.mobile.min.js:11
-
j.extend.successkendo.mobile.min.js:11
-
p.isFunction.fjquery.min.js:2
-
n.successkendo.mobile.min.js:11
-
l.fireWithjquery.min.js:2
-
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
0
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
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
but got the same error.
I tried to use
dataSource.query({ page: 1 });
0
Accepted
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.
In this way if you wish you can to pass the skip and take parameters too.
Another possible approach is to use the page method.
I hope this will help.
Kind regards,
Alexander Valchev
the Telerik team
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