开发者

telerik ASP.net MVC Grid Ajax binding problem

开发者 https://www.devze.com 2023-03-01 04:15 出处:网络
I\'m trying to use Telerik ASP.net MVC Grid, and find a problem. When I use a grid in an ordinary View with Ajax binding, it works well. However, when I put the grid in a partial View that is loaded

I'm trying to use Telerik ASP.net MVC Grid, and find a problem.

When I use a grid in an ordinary View with Ajax binding, it works well. However, when I put the grid in a partial View that is loaded by an Ajax call, the grid's Ajax binding does not work then. From firebug, I find the ajax request for getting 开发者_开发技巧data did not send to server side.

I find a similar question in stackoverflow : Telerik MVC: Loading Grid with ajax request don't work , but don't find solution.

Thank you!


I also have same problem and i find the solution basically it is due to telerik javascript file.

<%: Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true)) %>

copay and paste that code In master page before end of the body or if you are not using master page then place it on every page where u use ajax binding of telerik .


the reason is I used ClientEvents as below:

Html.Telerik().Grid(Model)
.....
.Selectable()
.ClientEvents(e => e.OnRowSelected("onRowSelected"))

and I put the js code of onRowSelected handler after the grid.

When I move the js code of onRowSelected before the grid, it works.


Try this in the OnSuccess event of the ajax call (in the AjaxOptions of the Ajax.ActionLink or Ajax.BeginForm)

OnSuccess = "function () {var html = $('#grid').html();$('#grid').html(html);}"

This force the ajax call for getting data.

0

精彩评论

暂无评论...
验证码 换一张
取 消