Skip to content

Commit

Permalink
Removed Pager Display Template, Now Its written by megridview.js,
Browse files Browse the repository at this point in the history
  • Loading branch information
mesuttalebi committed Dec 10, 2015
1 parent 67852a3 commit 8cab577
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 84 deletions.
14 changes: 1 addition & 13 deletions mesoft.gridview/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>() { 10,25, 50, 100},
ShowPageOptions= true,
TotalItems=1
}
};
return View(model);
return View();
}

public ActionResult GetCustomers(PagingInfo PagingData)
Expand Down
72 changes: 70 additions & 2 deletions mesoft.gridview/Scripts/megridview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
'<!-- Pager Left-->' +
'<div class="col-sm-6 col-xs-12">' +
'<!-- Page Size Area -->' +
'<div class="gridview-itemization">';
if (options.ShowPageOptions === true) {
pagerHtml += '<span>Page Size</span>' +
'<div class="btn-group selectlist dropup" data-resize="auto">' +
'<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">' +
'<span class="selected-label">' + options.ItemsPerPage + '</span>' +
'<span class="caret"></span>' +
'<span class="sr-only">' + options.PageSizeText + '&nbsp;</span>' +
'</button>' +
'<ul class="dropdown-menu" role="menu">';
for (var i = 0; i < options.PageOptions.length ; i++) {
pagerHtml += '<li data-value="' + options.PageOptions[i] + '"><a href="#">' + options.PageOptions[i] + '</a></li>';
}
pagerHtml += '</ul>' +
'<input class="hidden hidden-field" name="itemsPerPage" readonly="readonly" aria-hidden="true" type="text">' +
'</div>';
}
pagerHtml += '<span>' +
'<span class="gridview-start">1</span> - <span class="gridview-end">' + options.ItemsPerPage + '</span>' +
'(<span class="gridview-count">0</span>)' +
'</span>' +
'</div>' +
'<!-- / Page Size Area -->' +
'</div>' +
'<!-- Pager Right-->' +
'<div class="col-sm-6 col-xs-12 text-right">' +
'<!-- Pagination -->' +
'<div class="gridview-pagination">' +
'<button type="button" class="btn btn-default btn-sm gridview-prev" disabled="disabled">' +
'<span class="fa fa-chevron-left"></span>' +
'<span class="sr-only">Previous Page</span>' +
'</button>' +
'<label class="page-label" id="myPageLabel">&nbsp;' + options.PageText + '&nbsp;</label>' +
'<input type="number" class="form-control gridview-secondaryPaging active" aria-labelledby="myPageLabel" value="1">' +
'<span>' +
'/ <span class="gridview-pages">0</span>' +
'</span>' +
'<button type="button" class="btn btn-default btn-sm gridview-next">' +
'<span class="fa fa-chevron-right"></span>' +
'<span class="sr-only">Next Page</span>' +
'</button>' +
'</div>' +
'<!-- /Pagination -->' +
'</div>' +
'<!-- /Pager Right-->';

$(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);

Expand Down Expand Up @@ -338,6 +406,6 @@
$gridviewObject.CurrentPage = 1;
$gridviewObject.ItemsPerPage = $gridviewObject.PageOptions[0];
LoadData(obj);
}
}
};
}(jQuery));
6 changes: 2 additions & 4 deletions mesoft.gridview/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
@model mesoft.gridview.Models.CustomersViewModel

@{
@{
ViewBag.Title = "Home Page";
}

<div class="jumbotron">
<h1>MeSoft Gridview V0.3</h1>
<h1>MeSoft Gridview V0.3.1</h1>
<p class="lead">No Magic! Simple To Use, Simple to Develop</p>
<p><a href="#" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
</div>
Expand Down
7 changes: 2 additions & 5 deletions mesoft.gridview/Views/Home/_GridViewPartial.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@model mesoft.gridview.Models.CustomersViewModel

<!-- GRIDVIEW-->
<!-- GRIDVIEW-->
<div class="gridview gridview1">
<!-- GridView Header-->
<div class="gridview-header">
Expand Down Expand Up @@ -63,8 +61,7 @@
</div>
<!-- /GridView ViewPort-->
<!-- GridView Paging Area-->
<div class="gridview-footer">
@Html.DisplayFor(x => x.PagingInfo, "Pager")
<div class="gridview-footer">
</div>
<!-- /GridView Paging Area-->
</div>
Expand Down
58 changes: 0 additions & 58 deletions mesoft.gridview/Views/Shared/DisplayTemplates/Pager.cshtml

This file was deleted.

2 changes: 1 addition & 1 deletion mesoft.gridview/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\gridview.mdf;Initial Catalog=gridview;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\gridview.mdf;Initial Catalog=gridview;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion mesoft.gridview/mesoft.gridview.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<IISExpressAnonymousAuthentication>enabled</IISExpressAnonymousAuthentication>
<IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -193,7 +194,6 @@
<Content Include="Views\Home\About.cshtml" />
<Content Include="Views\Home\Contact.cshtml" />
<Content Include="Views\Home\Index.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\Pager.cshtml" />
<Content Include="Views\Home\_CustomersPartial.cshtml" />
<Content Include="Views\Home\_GridViewPartial.cshtml" />
</ItemGroup>
Expand Down

0 comments on commit 8cab577

Please sign in to comment.