joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
75 stars 56 forks source link

Paging and Global Search not working #155

Open bugrasitemkar opened 6 years ago

bugrasitemkar commented 6 years ago

Hello, First thank you, great grid solution.

I have a problem about paging and global search, grid displays my whole test data (51 rows) even when paging is set to 10 rows. Paging controls at the bottom and the text that indicates in which page I am are working fine except in every page, my whole data is seen. Also Global Search is not working. Sorting and Show/Hide columns drop down, and export button are working fine. I am suspecting a script error but there is nothing on developer console.

Here is my configuration:

            MVCGridDefinitionTable.Add("OrderTrackingGrid", new MVCGridBuilder<OrdeListModel>()
            .WithAuthorizationType(AuthorizationType.AllowAnonymous)
            .WithSorting(sorting: true, defaultSortColumn: "OrderID", defaultSortDirection: SortDirection.Dsc)
            .WithPaging(paging: true, itemsPerPage: 10, allowChangePageSize: true, maxItemsPerPage: 100)
            .WithAdditionalQueryOptionNames("Search")
            .WithAdditionalSetting("RenderLoadingDiv", false)
            //.WithAdditionalQueryOptionNames("search")
            .AddColumns(cols =>
            {
                cols.Add("OrderID").WithValueExpression(p => p.OrderID.ToString()).WithFiltering(true)
                .WithSorting(true).WithAllowChangeVisibility(true);
                cols.Add("OrderCode").WithHeaderText("Order Code")
                .WithValueExpression(p => p.OrderCode).WithFiltering(true)
                .WithSorting(true).WithAllowChangeVisibility(true);
                //cols.Add("LastName").WithHeaderText("Last Name")
                //    .WithValueExpression(p => p.LastName);
            })
            .WithRetrieveDataMethod((options) =>
            {
                var result = new QueryResult<OrdeListModel>();
                var orderlist = rp.GetOrderListForManagement();
                result.Items = orderlist;
                result.TotalRecords = orderlist.Count();
                return result;
            })
    );

Here is my view:


  <div class="panel panel-default">
    <div class="panel-body">

        @Html.Partial("_MVCGridToolbar", new AygazOrderTrack.Models.MVCGridToolbarModel()
   {
       MVCGridName = "OrderTrackingGrid",
       PageSize = true,
       ColumnVisibility = true,
       Export = true,
       GlobalSearch = true
   })
        @Html.MVCGrid("OrderTrackingGrid")
    </div>
</div>

and here is my scripts

<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>
<script src="/Scripts/modernizr-2.6.2.js"></script>
<script src="/Scripts/jquery-3.2.1.js"></script>
<script src="/MVCGridHandler.axd/script.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/respond.js"></script>  
<link href="/Content/Gridmvc.css" rel="stylesheet" type="text/css" />
tapan8 commented 6 years ago

For global search - http://mvcgrid.net/demo/globalsearch string globalSearch = options.GetAdditionalQueryOptionString("Search"); is missing

for paging - http://mvcgrid.net/demo/paging if (options.GetLimitOffset().HasValue) { query = query.Skip(options.GetLimitOffset().Value).Take(options.GetLimitRowcount().Value); } is missing