• MVC加jquery的无刷新列表分页摘要


    1.分页加载的js代码,分别有两种调用形式,
    一个是在页面客户端加载完成时$(function{..})   调用需要设置pageIndex与pagesize   
    另一个是点分页导航时调用,分页导航的地址是已经拼接好的不需要再提供参数

      function LoadLatelyTelRecord(pageIndex, pageSize) {
                var url = "";
                var resId = $("#hResId").val();
               
                if (pageIndex > 0 && pageSize > 0) {
                    url = "/MVC/RMS/LatelyTelRecord?pageSize=" + pageSize + "&pageIndex=" + pageIndex + "&resId=" + resId + "&tmp=" + Math.random();
                } else {
                     url = $(this).attr("href");
                }

                $("#latelyTRPanel").load(url, function() {
                    $("#ltrPager a").click(LoadLatelyTelRecord);
                    $("a.PostVisitRecord").click(PostVisitRecord);
                });
                return false;
            }

    2.控制器中的Action代码

            /// <summary>
            /// 我最近的电话记录
            /// </summary>
            /// <param name="pageIndex"></param>
            /// <param name="pageSize"></param>
            /// <returns></returns>
            public ActionResult LatelyTelRecord(int pageIndex, int pageSize,long resId)
            {
                ViewData["pageIndex"] = pageIndex;
                ViewData["pageSize"] = pageSize;
                ViewData["resId"] = resId;
                var pd = RMSModel.GetLatelyTelRecord(pageIndex, pageSize);
                return View(pd);
            }

    3.对应的View代码,需要生产分页导航中a标签的href属性为"/MVC/RMS/..."

    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    <%@ Import Namespace="XXX.CRM.Model" %>
    <%
    var pd
    =ViewData.Model as PagedDataSet<List<TelRecordModel>>;
    var paging
    = new F.Studio.Common.StringHelper.Paging();
    var pageSize
    = (int)(ViewData["pageSize"]);
    var pageIndex
    = (int)(ViewData["pageIndex"]);
    var resId
    = (long)(ViewData["resId"]);
    string url = string.Format("/MVC/RMS/LatelyTelRecord?pageIndex={0}&pageSize={1}&resId={2}", "{0}", pageSize, resId);
    var pagingStr
    = paging.Navigate(pd.Total, pageSize, 5, pageIndex, url);
    %>
    <table class="bfxx">
    <tr>
    <th width="5%">xxx</th>
    <th width="10%">xxx</th>
    <th width="15%">xxxx</th>
    <th width="10%">xxxx</th>
    <th width="20%">xxxx</th>
    <th width="20%">xxxx</th>
    <th width="20%">xxxx<img alt="刷新" src="/WebForm/images/isync.png" onclick="LoadLatelyTelRecord(1,<%=pageSize %>)" style="cursor:hand; 22px; height:22px;"></th>
    </tr>
    <%foreach (var item in pd.Data)
    {
    %>
    <tr>
    <td><%=item.Direction %></td>
    <td><%=item.CallingNum %></td>
    <td><%=item.CalledNum %></td>
    <td><%=item.Name %></td>
    <td><%=item.BTime %></td>
    <td><%=item.ETime %></td>
    <td>
    <div id="record">
    <div id="player">

    </div>
    <input type="button" onclick="play(this,'<%=item.Path %>','<%=item.RecordId %>')" value="Play" />
    <a href="" recordId="<%=item.RecordId %>" style='display:inline;' class="PostVisitRecord">Post</a>
    </div>
    </td>
    </tr>
    <%} %>
    <tr>
    <td colspan="7" id="ltrPager" class="pager">
    <%=pagingStr %>
    </td>
    </tr>
    </table>
  • 相关阅读:
    2019-3-24
    模板
    试试Markdown编辑器
    Codeforces Round #529 (Div. 3) D. Circular Dance
    Codeforces Round #529 (Div. 3) C. Powers Of Two(数学????)
    poj 2566"Bound Found"(尺取法)
    poj 3273"Monthly Expense"(二分搜索+最小化最大值)
    二分搜索
    Codeforces Round #518 (Div. 2) B LCM
    2018.12.21 浪在ACM 集训队第十次测试赛
  • 原文地址:https://www.cnblogs.com/wdfrog/p/2121807.html
Copyright © 2020-2023  润新知