Reputation: 401
I have a Grid.MVC based list which allows me to create a sortable, filterable, paged list.
Problem is, I can't seem to find anything in the documentation for Grid.MVC in particular to ouput a "count" of what has been filtered. I figured you may need a client side solution through potentially some jQuery code, but I was hoping maybe there was something easier.
@using GridMvc.Html
@model IEnumerable<Sample.Cases>
@{
ViewBag.Title = "Case Browse List";
}
<h2>Case Browse List</h2>
<p>
@Html.ActionLink("Add New Participant", "Create")
</p>
<div>
@Html.Grid(Model).Columns(columns =>
{
columns.Add().Encoded(false).Sanitized(false).SetWidth(30).RenderValueAs(model => @<b>@Html.ActionLink("Select", "Details", new { id = model.ID })</b>);
columns.Add(model => model.ID).Titled("ID");
columns.Add(model => model.FirstName).Titled("First Name");
columns.Add(model => model.MiddleName).Titled("Middle Name");
columns.Add(model => model.LastName).Titled("LastName");
columns.Add(model => model.LKPSuffixes.SuffixDescription).Titled("Suffix");
columns.Add(model => model.LKPCaseStatuses.CaseStatusDescription).Titled("Case Status");
columns.Add(model => model.CaseStatusDate).Titled("Case Status Date");
}).WithPaging(10).Sortable(true).Filterable(true).WithMultipleFilters()
</div>
Above is my view, it's quite simple, but I basically just need a footer below this grid that states how many results we have in total. This is filterable and paginated, so it should get a count of all records, not just the 10 displayed (.WithPaging(10)) or the total without filtering by anything in the columns.
Grid.MVC has a sample project very much like this here: http://gridmvc.azurewebsites.net/?grid-page=3
Edit - Ideally, the footer might say something like "Showing 1 to 10 of 57 entries", or if that's not possible, even just the total entries would do fine for our requirements.
Reading some of this code in their GitHub - it appears there are some attributes for the count of displayed or total rows (after filtering), so I feel like there must be some built-in way to do this, just not sure how.
https://github.com/leniel/Grid.Mvc/blob/master/GridMvc/IGrid.cs
Upvotes: 3
Views: 6265
Reputation: 14687
There's an option .WithGridItemsCount(string gridItemsName)
which allows you to display the total count.
So you can set something like -
.WithPaging(15).WithGridItemsCount("Total Orders")
Here's the output -
Upvotes: 6