Hi,
according to what is written in this answer, binding a grid on initial page (or view) load using BindTo will prevent the Ajax request (if there is any data).
IMHO, even if the there is no data, if I explicitly bind the grid, it should not make any other attempt to get the data.
Anyway, how can I prevent the request even if there is no initial data?
Thank you.
7 Answers, 1 is accepted
Hello Paola,
Have you tried using the autoBind option, documented here:
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-autoBind
Regards,
Kiril Nikolov
Telerik

I've tried setting Autobind(false) but I got "NotSupportedException: Cannot set AutoBind if widget is populated during initialization"
My grid is configured to works in batch editing mode similar to what is shown in the demo.
Thank you.
Hello Paola,
Thanks for the clarification.
I have talked about this with the team and currently such scenario is not supported. Currently the Grid will fetch data if nothing is present in the model. We cannot change this behavior as it will be a breaking change for lots of other users.
Regards,
Kiril Nikolov
Telerik

>> Currently the Grid will fetch data if nothing is present in the model
This is nonsense IMHO. The Kendo UI team should add an option to deal with this case, with a default value so to preserve backward compatibility.
Can you suggest a immediate workaround, please? I have a view with 3 grids and I'd like to avoid 3 useless AJAX calls.
Thank you.
Hello Paola,
You can submit this as a feature request on UserVoice, so that it is considered for implementation in a future release if it gets popular among the users. However we cannot make this change immediately as it will be breaking for multiple users.
Currently we do not have a viable workaround for this behavior.
Regards,
Kiril Nikolov
Telerik

I think this change will not be a breaking one if you add an option with a default value to preveserve current behaviour.
Anyway, I found a workaround and I like to share here for anyone who may need it.
Just hook the "RequestStart" event of the datasource; in the handler, check the value of a hidden field containing the ID of the model and if it's zero (or any other default value, like an empty guid) and the request is "read" then cancel the request:
1.
function
onRequestStart(e)
2.
{
3.
if
(e.type ===
"read"
&& $(
"#Id"
).val() ===
"0"
)
4.
{
5.
e.preventDefault();
6.
}
7.
}
Hello Paola,
Thanks for sharing the workaround.
We will further consider adding an option for this scenario.
Regards,
Kiril Nikolov
Telerik