【问题标题】:WebGrid paging href is changingWebGrid 分页 href 正在改变
【发布时间】:2014-04-06 02:45:53
【问题描述】:

我第一次进行分页时效果很好。当我将光标放在页脚分页上时,它看起来像

http://localhostt:62535/Account/Index?page=3

如果我在 WebGrid 上执行任何操作(编辑或删除或可见),则分页 url 将更改为类似

http://localhostt:62535/Account/VisibleCountry?Id=101&page=3

代码

@{
    ViewBag.Title = "Index";
        Layout = "~/Views/Shared/User.cshtml";
    WebGrid grid = new WebGrid(Model.OrderBy(m=>m.idVal), canSort: true, canPage: true, rowsPerPage: 20,
    selectionFieldName: "selectedRow", ajaxUpdateContainerId: "stategrid");
}



 <div id="countrygrid" align="center">

    @grid.GetHtml(tableStyle: "webGrid",
    headerStyle: "header",
    alternatingRowStyle: "alt",
    selectedRowStyle: "select",
    columns: new[] {
        grid.Column("CountryName","Country Name"),
        grid.Column("",header:"Action",format:@<text>
            @Html.ActionLink("Edit", "Edit", new {  id=item.CountryId })
            |
            @if (item.deleted == false)
            {
                 <a href="#?id=@item.CountryId" onclick="changeCountry(this)" title="Disable">Disable</a> 
            }
            else
            {
                <a href="#?id=@item.CountryId" onclick="ChangeCountry(this)" style="color:red" title="Enable">Enable</a> 
            }
        </text>),

        grid.Column("",header:"Action",format:@<text><a href="#"  id="@item.CountryId"  class="countryIdValues" >Addstate</a></text>)
    });

</div>

我不明白为什么网址会发生变化。谁能帮我解决这个问题?

【问题讨论】:

    标签: jquery asp.net-mvc webgrid


    【解决方案1】:

    您似乎正在使用 JQuery 使用异步回发来执行其他操作,例如编辑/删除/...您可以执行以下操作来解决问题,

    在所有其他操作后使用 Ajax 重置您的页面,例如编辑/删除/... 例如像这样在 JS 函数中触发重置事件

      $("#resetid").click();
    
      <input type="reset" id="resetid" value="Reset" name="Reset"/>
    

    或者如果您没有重置事件,请尝试重新加载 ajax 调用/页面。

    它对我有用,希望对你有帮助。!!!

    【讨论】:

      猜你喜欢
      • 2012-05-14
      • 2013-10-09
      • 2013-09-08
      • 2011-09-14
      • 1970-01-01
      • 2023-03-15
      • 2012-09-15
      • 2017-06-03
      • 2012-06-21
      相关资源
      最近更新 更多