【问题标题】:webgrid paging click makes grid state goes wrongwebgrid 分页点击使网格状态出错
【发布时间】:2016-06-26 12:48:21
【问题描述】:

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( ....

部分视图包含网格按钮单击事件的脚本以及这一行

 $('.edit-mode').hide();

主视图

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

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

主视图调用局部视图

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

【问题讨论】:

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


    【解决方案1】:

    修改部分视图(将 getHTML 移到父 div 之外)消除了我指定的问题。

    <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( ....

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-05
      • 2012-11-30
      • 2013-01-16
      • 2013-04-21
      • 2012-05-13
      • 2012-05-14
      • 2013-10-09
      • 1970-01-01
      相关资源
      最近更新 更多