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

Prevent initial request to get data

7 Answers 1395 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paola
Top achievements
Rank 1
Paola asked on 29 Dec 2015, 11:16 PM

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

Sort by
0
Kiril Nikolov
Telerik team
answered on 30 Dec 2015, 02:19 PM

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Paola
Top achievements
Rank 1
answered on 30 Dec 2015, 05:29 PM

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.

0
Kiril Nikolov
Telerik team
answered on 04 Jan 2016, 11:26 AM

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Paola
Top achievements
Rank 1
answered on 04 Jan 2016, 05:00 PM

>> 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.

0
Kiril Nikolov
Telerik team
answered on 05 Jan 2016, 09:09 AM

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Paola
Top achievements
Rank 1
answered on 08 Jan 2016, 08:38 AM

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.}

This prevents the unnecessary server requests when the user wants to insert a new record but not if he wants to edit it.
0
Kiril Nikolov
Telerik team
answered on 12 Jan 2016, 07:29 AM

Hello Paola,

 

Thanks for sharing the workaround.

 

We will further consider adding an option for this scenario.

 

Regards,
Kiril Nikolov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Paola
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Paola
Top achievements
Rank 1
Share this question
or