Added feature To display Grid filtered count

Jul 4, 2014 at 1:03 PM
Edited Jul 23, 2014 at 11:55 AM
HI,

I've added some code to display grid items count.
In this feature, After filtered the grid, it'll show the filtered items count.
To show display the items count, we need to call the method

with the four option
1.WithGridItemsCount("Orders items count")
2.WithGridItemsCount(string.Empty)
3.WithGridItemsCount(null)
4.WithGridItemsCount(" ")

Please review it and tell me. I am waiting for Your acknowledgement
_Grid.Cshtml

      @RenderGridItemsCount()



@helper RenderGridItemsCount()
{
        if(Model.RenderOptions.ShowGridItemsCount)
        {
            /*Use Bootstrap css for this design*/
            <caption>
                 <div class="row">
                      <div class="span6"></div>
                      <div class="span6">
                          <div class="row">
                              <div class="span5 grid-items-count-displayName">
                                  @Model.RenderOptions.gridCountDisplayName
                              </div>
                              <div class="span1 grid-items-count">
                                  @Model.GridItemsCount
                              </div>
                          </div>
                      </div>
                 </div>
            </caption>
        }
}
GridRenderOptions.cs
        /// <summary>
        ///     Does items count need to show
        ///     - Author Jeeva J
        /// </summary>
        public bool ShowGridItemsCount { get; set; }

        /// <summary>
        ///     To show string while show grid items count
        ///     - Author Jeeva J
        /// </summary>
        public string gridCountDisplayName { get; set; }
HtmlGrid.cs
        /// <summary>
        ///     To show Grid Items count
        ///     - Author by Jeeva
        /// </summary>
        int IGrid.GridItemsCount
        {
            get { return _source.GridItemsCount; }
        }
Grid.cs
        /// <summary>
        ///    Return Grid items count
        ///    - After filtered, this will return only filtered items count
        ///    - Author - Jeeva J
        /// </summary>
        public int GridItemsCount
        {
            get { return GridItems.Count(); }
        }
GridHtmlOptions.cs
        /// <summary>
        ///     Set to true if we want to show grid itmes count
        ///     - Author - Jeeva J
        /// </summary>
        /// <param name="gridItemsName">Grid items name - To show text while display count</param>
        /// <returns></returns>
        public IGridHtmlOptions<T> WithGridItemsCount(string gridItemsName)
        {
            if (string.IsNullOrWhiteSpace(gridItemsName))
                gridItemsName = "Grid Items count";

            _source.RenderOptions.gridCountDisplayName = gridItemsName;
            _source.RenderOptions.ShowGridItemsCount=true;
            return this;
        }
IGridHtmlOptions.cs
        /// <summary>
        ///    Allow grid to show Grid items count
        /// </summary>
        /// <returns></returns>
        IGridHtmlOptions<T> WithGridItemsCount(string gridItemsName);
IGrid.cs
        /// <summary>
        ///     To get Grid items count
        ///     - After filter, it'll show only the filtered items count
        /// </summary>
        /// <returns></returns>
        int GridItemsCount { get; }
To call in cshtml (To implement this)
To implement this call like "WithGridItemsCount("Orders items count")" in cshtml 
For example
@Html.Grid(Model).Named("ordersGrid").Columns(columns =>
    {
       // our code is here

    }).WithPaging(10).Sortable().Filterable().WithMultipleFilters().WithGridItemsCount("Orders items count")
Css
                /*Grid items count*/
.grid-items-count-displayName, .grid-items-count {
    font-weight:bold;
}

caption { caption-side: bottom; text-align:right; margin-top:9px;}
Coordinator
Jul 28, 2014 at 3:51 AM
Jul 30, 2014 at 10:40 AM
Edited Jul 30, 2014 at 10:45 AM
Nice to hear.. Thanks a lot Bukharin. :-) ...
Jul 30, 2014 at 2:39 PM
Hello, could u please update the nuget package of grid.mvc ? I am in need of this kind of functionality, though in nuget package manager it shows only version 3.0.0. Thank you in advance