GithubHelp home page GithubHelp logo

jundie.net.core_pager's Introduction

骏蝶 asp.net core pager 分页系统 Ver1.0.5

有问题请点击上面的“Issues”, Please click on the "Issues" above question.

View:

@addTagHelper "*, jundie.net.core_pager"
@model IEnumerable<jundie.net.core_pager.demo_cn.models.article>
@{
    ViewData["Title"] = "分页示例";
    ViewData["menu_demo"] = "active";
    var pagerOption = ViewData["pagerOption"] as jundie.net.core_pager.PagerOptions;
}
<h3>@ViewData["Message"]</h3>
<div class="panel panel-default">
    <!-- Default panel contents -->
    <div class="panel-heading">
    	@ViewData["Title"] (@pagerOption.Total)
    </div>
    <!-- Table -->
    <table class="table table-striped table-bordered">
        <thead>
            <tr>
                <th>@Html.DisplayNameFor(model => model.Title)</th>
                <th>@Html.DisplayNameFor(model => model.Author)</th>
                <th>@Html.DisplayNameFor(model => model.Source)</th>
            </tr>
        </thead>
        <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@item.Title</td>
                <td>@item.Author</td>
                <td>@item.Source</td>
            </tr>
        }
        </tbody>
    </table>
</div>
<V6-pager pager-option="pagerOption"></V6-pager>
	

Controller:

public IActionResult index(string keyword, int page = 1)
{
    var model = demo_data.AllArticles.OrderByDescending(m => m.PubDate).AsQueryable();
    if (!string.IsNullOrEmpty(keyword))
    {
        model = model.Where(m => m.receiver.Contains(keyword));
    }
    var pagerOption = new PagerOptions
    {
        CurrentPage = page,
        PageSize = 10,
        Total = model.Count(),
        RouteUrl = Url.Action(nameof(Index), new { keyword }),
        PageIndexParameterName = "page"
    };
    ViewData["pagerOption"] = pagerOption;
    var list = model.Skip((pagerOption.CurrentPage - 1) * pagerOption.PageSize).Take(pagerOption.PageSize);
    return View(list);
}
	

jundie.net.core_pager's People

Contributors

valucn avatar

Stargazers

 avatar

Watchers

 avatar

jundie.net.core_pager's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.