asp.net mvc grid paging sorting filtering listeleme sayfalama filtreleme

  1. yasin
    2
    212
    16.12.2019 18:12:00

    aşağıda ki linkte core ile gridde yapılan sayfalama, arama, sıralama, filtreleme işlemlerine benim asp.net mvc de ihtıyacım var. var mı bana da bir verebileceğiniz örnek bir uygulama ?

    https://code.replyfeed.com/sorular/6092/asp-net-core-mvc-sayfalama-pagination-paging

    asp.net-mvc c# 7 ay önce 345 Görüntüleme

( 1 ) Cevap

  1. koraydrk
    1
    2539
    17.12.2019 17:06:00

    System.Web.Helpers altındaki WebGrid den yararlanabilirsin

    @model List<WebgridPagingSortingFiltering.Models.Employee>
    @{
        Layout = null;
        var grid = new WebGrid(canPage: true, rowsPerPage: 10);
        grid.Bind(source: Model, rowCount: ViewBag.TotalRows, autoSortAndPage: false);
    }
    <!DOCTYPE html>
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
        <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    </head>
    <body>
        <div class="container">
            <h2>code.replyfeed.com sayfalama</h2> 
            <nav class="navbar navbar-default">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <a href="#" class="navbar-brand">Search</a>
                    </div>
                    <div class="collapse navbar-collapse">
                        @using (Html.BeginForm("index","home", FormMethod.Get,new{@class="navbar-form navbar-left"}))
                        {
                            <div class="form-group">
                                <input type="text" name="search" value="@ViewBag.search" class="form-control" placeholder="search" />
                            </div>
                            <button type="submit" value="Search" class="btn btn-success">Search</button>
                        }
                    </div>
                </div>
            </nav>
            <div>
                @grid.Table(
                    tableStyle: "table table-responsive table-bordered",
                    columns: grid.Columns(
                        grid.Column(columnName:"FirstName", header: "First Name"),
                        grid.Column(columnName:"LastName", header: "Last Name"),
                        grid.Column(columnName: "EmailID", header: "Email"),
                        grid.Column(columnName: "City", header: "City"),
                        grid.Column(columnName:"Country", header: "Country")
                    )
                )
                <div class="row">
                    <div class="col-sm-6">
                        @grid.PagerList(mode: WebGridPagerModes.All, paginationStyle: "pagination pagination-small pagination-right")
                    </div>
                </div>
                @Html.Hidden("dir", grid.SortDirection)
                @Html.Hidden("col", grid.SortColumn)
            </div>
        </div>
        <script src="~/Scripts/jquery-3.1.1.js"></script>
        <script src="~/Scripts/bootstrap.min.js"></script>
        <script>
            $(function () {
                try {
                    var dir = $('#dir').val();
                    var col = $('#col').val();
                    var header = $("th a[href*=" + col + "]");
                    if (dir == "Ascending") {
                        header.text(header.text() + "  ^")
                    }
                    if (dir == "Descending") {
                        header.text(header.text() + "  ¡");
                    }
                } catch (e) {
                }
            })
        </script>
    </body>
    </html>
    

    asp net mvc paging sayfalama search

    Çalışan ugyulama kaynak kodlarını buradan alabilirsiniz

    https://github.com/replyfeed/Asp.Net-Mvc-Grid-Paging-Sorting-Filtering

Cevabınız