.net core 學習筆記(1)-分頁控制項的使用

來源:互聯網
上載者:User

標籤:asc   define   mode   tps   更新   開發   att   添加   document   

最近有個小項目,用.net core開發練練手,碰到的第一個問題就是分頁控制項的問題,自己寫太費時間,上網查了下,發現有人已經封裝好了的,就拿過來用了,分頁控制項github:https://github.com/sgjsakura/AspNetCore/blob/master/PagerDemo.md

使用方法也很簡單

後台代碼如下:期中list是資料返回的資料,pagesize是每頁的數量,page是當前頁數,totalcount-總條數,pagenum-總頁數

   var model= new PagedList<List<user>,user>(list, list.ToList(), pagesize, page, totalcount, pagenum);

  前台:

<ul class="pagination">    <pager setting-link-attr-data-ajax="true" setting-link-attr-data-ajax-update="#list" generation-mode="ListOnly" setting-link-attr-data-ajax-searchForm="#SearchForm" />    <li>當前:@Model.PageIndex 頁 總共:@Model.TotalPage 頁</li></ul>

 

setting-link-attr後面跟的參數都是jquery.unobtrusive-ajax.js的巨集指令引數,
data-ajax-是否是非同步ajax分頁,
data-ajax-update-需要更新的html標籤id,
data-ajax-searchForm-分頁時需要傳遞的查詢表單(PS:該屬性是發現了分頁沒有頁面已有的查詢條件傳遞過去,修改unobtrusive源碼手動添加的,)
 $(document).on("click", "a[data-ajax=true]", function (evt) {        evt.preventDefault();//  //下面為修改的源碼部分,用來處理頁面查詢表單參數        var currentform = $(this.getAttribute("data-ajax-searchForm"))//        var cdata = [];        if (currentform != undefined) {            cdata = $(currentform).serializeArray();        }//  //end        asyncRequest(this, {            url: this.href,            type: "GET",            data: cdata        });    });

  

.net core 學習筆記(1)-分頁控制項的使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.