From 8cab5777049f995bc2e02b9291dfdc512aaa0a9c Mon Sep 17 00:00:00 2001 From: mesuttalebi Date: Thu, 10 Dec 2015 22:24:08 +0200 Subject: [PATCH] Removed Pager Display Template, Now Its written by megridview.js, --- mesoft.gridview/Controllers/HomeController.cs | 14 +--- mesoft.gridview/Scripts/megridview.js | 72 ++++++++++++++++++- mesoft.gridview/Views/Home/Index.cshtml | 6 +- .../Views/Home/_GridViewPartial.cshtml | 7 +- .../Shared/DisplayTemplates/Pager.cshtml | 58 --------------- mesoft.gridview/Web.config | 2 +- mesoft.gridview/mesoft.gridview.csproj | 2 +- 7 files changed, 77 insertions(+), 84 deletions(-) delete mode 100644 mesoft.gridview/Views/Shared/DisplayTemplates/Pager.cshtml diff --git a/mesoft.gridview/Controllers/HomeController.cs b/mesoft.gridview/Controllers/HomeController.cs index bbed286..76e682d 100644 --- a/mesoft.gridview/Controllers/HomeController.cs +++ b/mesoft.gridview/Controllers/HomeController.cs @@ -11,19 +11,7 @@ public class HomeController : Controller { public ActionResult Index() { - var model = new CustomersViewModel() - { - Customers = null, - PagingInfo = new PagingInfo() - { - CurrentPage=1, - ItemsPerPage= 10, - PageOptions = new List() { 10,25, 50, 100}, - ShowPageOptions= true, - TotalItems=1 - } - }; - return View(model); + return View(); } public ActionResult GetCustomers(PagingInfo PagingData) diff --git a/mesoft.gridview/Scripts/megridview.js b/mesoft.gridview/Scripts/megridview.js index d2e8a98..8984cb5 100644 --- a/mesoft.gridview/Scripts/megridview.js +++ b/mesoft.gridview/Scripts/megridview.js @@ -8,11 +8,79 @@ var $gridviewObject = new Object(); + var options = { + ShowPageOptions : true, + ItemsPerPage : 10, + PageOptions: [10, 20, 50, 100], + PageSizeText: "Page Size", + PageText: "Page" + } + + //A function to Automatically insert page options + var writePagerHtml = function (obj) { + var pagerHtml = + '' + + '
' + + '' + + '
'; + if (options.ShowPageOptions === true) { + pagerHtml += 'Page Size' + + '
' + + '' + + '' + + '' + + '
'; + } + pagerHtml += '' + + '1 - ' + options.ItemsPerPage + '' + + '(0)' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '' + + '' + + '' + + '' + + '/ 0' + + '' + + '' + + '
' + + '' + + '
' + + ''; + + $(obj).find('div.gridview-footer').html(pagerHtml); + } + + return this.each(function () { //The gridview object that we are working on it var gridview = this; - + + //Inserts Pager Html + writePagerHtml(gridview); + + // Get First Page LoadFirstPage(gridview); @@ -338,6 +406,6 @@ $gridviewObject.CurrentPage = 1; $gridviewObject.ItemsPerPage = $gridviewObject.PageOptions[0]; LoadData(obj); - } + } }; }(jQuery)); diff --git a/mesoft.gridview/Views/Home/Index.cshtml b/mesoft.gridview/Views/Home/Index.cshtml index 8f3473a..01152b3 100644 --- a/mesoft.gridview/Views/Home/Index.cshtml +++ b/mesoft.gridview/Views/Home/Index.cshtml @@ -1,11 +1,9 @@ -@model mesoft.gridview.Models.CustomersViewModel - -@{ +@{ ViewBag.Title = "Home Page"; }
-

MeSoft Gridview V0.3

+

MeSoft Gridview V0.3.1

No Magic! Simple To Use, Simple to Develop

Learn more »

diff --git a/mesoft.gridview/Views/Home/_GridViewPartial.cshtml b/mesoft.gridview/Views/Home/_GridViewPartial.cshtml index 43b83b9..0ca82c6 100644 --- a/mesoft.gridview/Views/Home/_GridViewPartial.cshtml +++ b/mesoft.gridview/Views/Home/_GridViewPartial.cshtml @@ -1,6 +1,4 @@ -@model mesoft.gridview.Models.CustomersViewModel - - +
@@ -63,8 +61,7 @@
- diff --git a/mesoft.gridview/Views/Shared/DisplayTemplates/Pager.cshtml b/mesoft.gridview/Views/Shared/DisplayTemplates/Pager.cshtml deleted file mode 100644 index da4dfde..0000000 --- a/mesoft.gridview/Views/Shared/DisplayTemplates/Pager.cshtml +++ /dev/null @@ -1,58 +0,0 @@ -@model mesoft.gridview.Models.PagingInfo - -
- -
\ No newline at end of file diff --git a/mesoft.gridview/Web.config b/mesoft.gridview/Web.config index be22c3b..649e736 100644 --- a/mesoft.gridview/Web.config +++ b/mesoft.gridview/Web.config @@ -9,7 +9,7 @@
- + diff --git a/mesoft.gridview/mesoft.gridview.csproj b/mesoft.gridview/mesoft.gridview.csproj index 67c233a..dc576de 100644 --- a/mesoft.gridview/mesoft.gridview.csproj +++ b/mesoft.gridview/mesoft.gridview.csproj @@ -20,6 +20,7 @@ enabled disabled + true @@ -193,7 +194,6 @@ -