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

Grid sends Ajax request when grid is empty

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tor
Top achievements
Rank 1
Tor asked on 17 Jul 2012, 06:34 PM
In my project I am using an MVC grid in client mode.
I have noticed that the MVC grid sends an ajax request to the server during rendering when the grid is empty. I debugged the grid Java Script file and there is indeed an ajax call being fired. However it seems to only make the call whenever the grid renders with zero rows. What is the purpose of this call?
The request reolves to the default route in my application. I would like to prevent this call since it's sending an invalid request to my default action. Is there a setting to prevent it.

I am not sure if this is related, but the grid doesn't seem to respect the client operation mode setting if the grid is empty. Clicking column headers (sort) will cause a request to go to the server if the grid is empty. This request seems to also resolve to the default route.

Thanks
  

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 18 Jul 2012, 08:53 AM
Hi Tor,

 By design the grid makes an Ajax request when rendered empty from the server side. This is useful in many situations - especially when the grid is ajax bound only (no server side data is passed). If you want to prevent this from happening you should handle the OnDataBinding event and call preventDefault:

function onDataBinding(e) {
   e.preventDefault();
}

Regards,
Atanas Korchev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Grid
Asked by
Tor
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or