I have a scenario where I would like to load the data for the Grid locally on the first page load, and then have the Grid use a remote datasource for any subsequent paging.
Take search for example. A user enters search parameters that are POSTed to the server, which then finds results and displays them in a grid on a page. Since I have those first set of results on the server when I'm rendering the page the first time, I want to load the Grid with them. But, then I want to use ajax for any paging beyond that first set.
What's the best way to do that?
Take search for example. A user enters search parameters that are POSTed to the server, which then finds results and displays them in a grid on a page. Since I have those first set of results on the server when I'm rendering the page the first time, I want to load the Grid with them. But, then I want to use ajax for any paging beyond that first set.
What's the best way to do that?
5 Answers, 1 is accepted
0
Josh
Top achievements
Rank 1
answered on 14 Jul 2013, 03:49 AM
I actually have an approach that is working for me. However, I would still love to know if there is a better (or more Kendo'ish) way to do this:
// somewhere at a scope the datasource can access set the variable:
var
bFirstRun =
true
;
// in the datasource, set:
transport: {
read:
function
(options) {
console.log(options);
if
(bFirstRun)
{
options.success({
rows: {{ rows|to_json }},
totalRows: {{ totalRows }}
});
bFirstRun =
false
;
}
else
{
$.post(
"{% url 'search_url' %}"
, $.param(options.data) + $(
"#search-form"
).serialize())
.done(
function
( data ) {
console.log(
"Returned post data:"
, data);
options.success(data);
})
.fail(
function
( data ) {
console.log(
"Post failed:"
, data);
options.error(data);
});
}
}
}
0
Accepted
Hi Joshua,
Thank you for getting in touch with us.
The DataSource does not provide a build-in mixed (local and remote) transport. The only suitable way to achieve that is by implementing custom read transport function like in your code snippet.
Regards,
Alexander Valchev
Telerik
Thank you for getting in touch with us.
The DataSource does not provide a build-in mixed (local and remote) transport. The only suitable way to achieve that is by implementing custom read transport function like in your code snippet.
Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Josh
Top achievements
Rank 1
answered on 16 Feb 2015, 04:13 PM
Is this supported now? Can the example provided be adapted to work with paging?
0
Josh
Top achievements
Rank 1
answered on 16 Feb 2015, 05:02 PM
Josh - the example I provided has been working fine for us and supports paging.
I've not seen any change on the Telerik side to enable this in any built-in way, and I wouldn't expect it... but, they can of course reply with any further details. ;)
I've not seen any change on the Telerik side to enable this in any built-in way, and I wouldn't expect it... but, they can of course reply with any further details. ;)
0
Hello guys,
Josh, I can confirm that there is still no build-in way provide a build-in mixed (local and remote) transport.
Regards,
Alexander Valchev
Telerik
Josh, I can confirm that there is still no build-in way provide a build-in mixed (local and remote) transport.
Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!