webgrid分页单击使网格状态出错

时间:2016-03-11 10:15:04

标签: javascript jquery asp.net-mvc-3 webgrid

screen shot shows webgrid state after paging number clicked

分页工作,网格添加/更新/删除按预期工作。 Ajaxcontainer工作正常,只替换页面上的网格点击而不是仅用webgrid替换整个页面。唯一的问题是网格模式崩溃了吗?我失踪的地方。

部分视图



<div id="gridposition" style="overflow: scroll; height: 300px; overflow-x: hidden;">
    <a href="javascript://" id="btnAddNew">Add New(+)</a>

    @{
        var grid = new WebGrid(source: Model, canPage: true, defaultSort: "QuestionID", rowsPerPage: 3, ajaxUpdateContainerId: "gridposition");
    }

    <div id="gridContent" style="padding-right: 30%;">
        @grid.GetHtml(htmlAttributes: new { id = "result" },  
         tableStyle: "wGrid",
         fillEmptyRows: false,
         alternatingRowStyle: "alt",
         headerStyle: "gridHeader",
         mode: WebGridPagerModes.All,
         firstText: "<< First",
         previousText: " < Previous",
         nextText: "Next >",
         lastText: "Last >>",
        emptyRowCellValue: null,
    columns:
        grid.Columns( ....
&#13;
&#13;
&#13;

部分视图包含网格按钮点击事件的脚本以及此行

&#13;
&#13;
 $('.edit-mode').hide();
&#13;
&#13;
&#13;

主视图

&#13;
&#13;
var url = '@Url.Action("Filter","AddSurveyQuestions")';
        $.get(url, { campaignid: campaignid, languagename: languagename }, function (result) {

            $('#SurveyViewGrid').html(result);
        }); ....
&#13;
&#13;
&#13;

主视图调用部分视图

&#13;
&#13;
<div id="SurveyViewGrid">
                @Html.Partial("SurveyView", Model.SurveyQuestions)
            </div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

修改的局部视图(在父div之外移动getHTML)消除了我指定的问题。

<div id="gridposition" style="overflow: scroll; height: 300px; overflow-x: hidden;">
    <a href="javascript://" id="btnAddNew">Add New(+)</a>

    @{
        var grid = new WebGrid(source: Model, canPage: true, defaultSort: "QuestionID", rowsPerPage: 3, ajaxUpdateContainerId: "gridposition");
    }
    </div>

    <div id="gridContent" style="padding-right: 30%;">
        @grid.GetHtml(htmlAttributes: new { id = "result" },  
         tableStyle: "wGrid",
         fillEmptyRows: false,
         alternatingRowStyle: "alt",
         headerStyle: "gridHeader",
         mode: WebGridPagerModes.All,
         firstText: "<< First",
         previousText: " < Previous",
         nextText: "Next >",
         lastText: "Last >>",
        emptyRowCellValue: null,
    columns:
        grid.Columns( ....