Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax MVC3 WebGrid在使用筛选器进行排序或分页后消失_Ajax_Asp.net Mvc 3_Webgrid - Fatal编程技术网

Ajax MVC3 WebGrid在使用筛选器进行排序或分页后消失

Ajax MVC3 WebGrid在使用筛选器进行排序或分页后消失,ajax,asp.net-mvc-3,webgrid,Ajax,Asp.net Mvc 3,Webgrid,我也有同样的问题 我已经创建了一个过滤器,它应该与WebGrid一起工作。过滤器适用于第一页,但如果您尝试转到其他页或对结果进行排序,则过滤器将丢失。我按照上一个问题中的建议更改了GET的方法,但是目标没有得到更新,而是从页面上消失了 div“Grid”中的Grid调用: 过滤形式: @using (Ajax.BeginForm("Action", new { filter = "filter" }, new AjaxOptions { InsertionMode = InsertionMode

我也有同样的问题

我已经创建了一个过滤器,它应该与WebGrid一起工作。过滤器适用于第一页,但如果您尝试转到其他页或对结果进行排序,则过滤器将丢失。我按照上一个问题中的建议更改了GET的方法,但是目标没有得到更新,而是从页面上消失了

div“Grid”中的Grid调用:

过滤形式:

@using (Ajax.BeginForm("Action", new { filter = "filter" }, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "Grid", HttpMethod = "Get" }))
如果在操作中设置了“filter”,则返回网格的PartialView,而不是完整视图

Firebug向我展示了正确的HTML被发送到响应中,但不管出于什么原因,它都没有被插入到Grid div中

如有任何建议,将不胜感激


编辑:我目前的解决方法是使用HTML表单而不是AJAX,但如果可能的话,我希望坚持使用AJAX。

我找到了解决这个问题的方法,我的Webgrid周围有一个div,如下所示:

Index.cshtml:

<div class="grid-container">
    <div id="my-grid">
        @Html.Partial("_Grid", Model)
    </div>
</div>
<div class="grid-container">
    @Html.Partial("_Grid", Model)
</div>
在我的列表中进行排序时,在筛选的结果上,Webgrid消失,没有插入my-grid-div。但是,当我将周围的“my grid”放在局部视图中时,它工作了。我不知道为什么,但它现在起作用了

Index.cshtml:

<div class="grid-container">
    <div id="my-grid">
        @Html.Partial("_Grid", Model)
    </div>
</div>
<div class="grid-container">
    @Html.Partial("_Grid", Model)
</div>

@部分(“_网格”,模型)
_Grid.cshtml:

@{

    var grid = new WebGrid(null, 
        canSort: true, 
        rowsPerPage: 20,
        ajaxUpdateContainerId: "my-grid");

    grid.Bind(Model.Models, autoSortAndPage: true, rowCount: Model.TotalModelCount);
}
[...]
<div id="my-grid">
@{

    var grid = new WebGrid(null, 
        canSort: true, 
        rowsPerPage: 20,
        ajaxUpdateContainerId: "my-grid");

    grid.Bind(Model.Models, autoSortAndPage: true, rowCount: Model.TotalModelCount);
}
[...]
</div>

@{
var grid=新WebGrid(空,
坎索特:没错,
行页码:20,
ajaxUpdateContainerId:“我的网格”);
Bind(Model.Models,autoSortAndPage:true,rowCount:Model.TotalModelCount);
}
[...]

cederlof,这种行为令人困惑和沮丧,但我感谢你分享这个答案。