This question is locked. New answers and comments are not allowed.
Hi,
We’re using the Telerik MVC grids in Ajax mode with Client operation, and manually binding JSON data to them. However, they’re making a POST request back to the controller action that returned the view. I initially thought it occurred every time we bound the grid, but I’ve since realized that just having the grid in the view causes the POST, even if we don’t bind to it.
Here's a sample grid:
And here's how we're binding it:
In the example above I'm using jQuery to call the MyController/MyJsonAction method to get the data to bind the grid. MyController also has a method, MyView, which just returns a view (which contains the grid). I noticed the extra POST once I decorated MyView with the HttpGet attribute, because the grid prompts me with an alert that it's received a 404 response (specifically, "Error! The requested URL returned 404 - Not Found"), since it can't find a "MyView" method that accepts a POST. I'm certain the message came from the Telerik grid because I searched the entire solution for the phrase "The requested URL" and it only showed up in the Telerik scripts.
My colleague spoke to a Telerik representative at TechEd, and they directed us here - they said either we've configured the grid incorrectly, or it's a bug. So, can anyone help us figure out what's going on here?
Thanks!
We’re using the Telerik MVC grids in Ajax mode with Client operation, and manually binding JSON data to them. However, they’re making a POST request back to the controller action that returned the view. I initially thought it occurred every time we bound the grid, but I’ve since realized that just having the grid in the view causes the POST, even if we don’t bind to it.
Here's a sample grid:
@(Html.Telerik().Grid <MyVM>().HtmlAttributes(new { style = "border-style: none;" }) .Name("MyGrid") .Columns(columns => { columns.Bound(a => a.Company).Title(ViewsResource.Global_Company); columns.Bound(a => a.PersonName).Title(ViewsResource.Global_Name); columns.Bound(a => a.Login).Title(ViewsResource.Global_EmailAddress); }) .ClientEvents(events => events.OnDataBinding("onDataBinding")) .DataBinding(dataBinding => dataBinding.Ajax().OperationMode(GridOperationMode.Client)) .Groupable() .Sortable() .Filterable() .ColumnContextMenu() .Reorderable(o => o.Columns(true)) .Resizable(o => o.Columns(true)))And here's how we're binding it:
<script type="text/javascript"> var logins; $(document).ready(function () { loadLogins(); }); function onDataBinding(e) { var grid = $(this).data("tGrid"); if (logins != null) { grid.dataBind(logins); } } function loadLogins() { loadingIndicator_Start(); $.ajax({ type: "POST", dataType: "json", contentType: "application/json; charset=utf-8", url: '/MyController/MyJsonAction', success: function (data) { logins = data; var grid = $("#MyGrid").data("tGrid"); grid.rebind(); }, complete: function () { loadingIndicator_Stop(); } }); }</script>In the example above I'm using jQuery to call the MyController/MyJsonAction method to get the data to bind the grid. MyController also has a method, MyView, which just returns a view (which contains the grid). I noticed the extra POST once I decorated MyView with the HttpGet attribute, because the grid prompts me with an alert that it's received a 404 response (specifically, "Error! The requested URL returned 404 - Not Found"), since it can't find a "MyView" method that accepts a POST. I'm certain the message came from the Telerik grid because I searched the entire solution for the phrase "The requested URL" and it only showed up in the Telerik scripts.
My colleague spoke to a Telerik representative at TechEd, and they directed us here - they said either we've configured the grid incorrectly, or it's a bug. So, can anyone help us figure out what's going on here?
Thanks!