Skip to content

Commit

Permalink
Name Changed to MT.GridView Updated to 0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mesut Talebi committed Jan 20, 2018
1 parent f1be6df commit 387aaed
Show file tree
Hide file tree
Showing 34 changed files with 521 additions and 167 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ $RECYCLE.BIN/


#Publish Settings
PublishProfiles/
PublishProfiles/
/.vs/config/applicationhost.config
Binary file added 2018-01-20_16-13-55.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions gridview.sln → MT.GridView.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mesoft.gridview", "mesoft.gridview\mesoft.gridview.csproj", "{464C497C-52CF-4398-88B5-B812E0B1EBB7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MT.GridView", "mesoft.gridview\MT.GridView.csproj", "{464C497C-52CF-4398-88B5-B812E0B1EBB7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ A Simple Gridview To Use in Asp.net mvc projects.

With this gridview we can simply show data in a grid view, sort on every field we want, and search on data with any fields we want, also we can add custom filters to gridview.

<img src="2018-01-20_16-13-55.gif" />
6 changes: 2 additions & 4 deletions mesoft.gridview/App_Start/BundleConfig.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Web;
using System.Web.Optimization;

namespace mesoft.gridview
namespace MT.GridView
{
public class BundleConfig
{
Expand All @@ -21,14 +21,12 @@ public static void RegisterBundles(BundleCollection bundles)

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js",
"~/Scripts/megridview.js"));
"~/Scripts/respond.js"));

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/bootstrap-theme.css",
"~/Content/font-awesome.min.css",
"~/Content/megridview.css",
"~/Content/site.css"));

// Set EnableOptimizations to false for debugging. For more information,
Expand Down
2 changes: 1 addition & 1 deletion mesoft.gridview/App_Start/FilterConfig.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Web;
using System.Web.Mvc;

namespace mesoft.gridview
namespace MT.GridView
{
public class FilterConfig
{
Expand Down
2 changes: 1 addition & 1 deletion mesoft.gridview/App_Start/RouteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Web.Mvc;
using System.Web.Routing;

namespace mesoft.gridview
namespace MT.GridView
{
public class RouteConfig
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
megridview v0.3.1
megridview v0.3.3
Developed By Mesut Talebi (mesut.talebi@yahoo.com)
Open Source And no licence :) free to use
*/
Expand Down Expand Up @@ -64,7 +64,7 @@ overflow-y: auto;
.gridview .gridview[data-currentview="list"] .gridview-loader {
margin-top: -12px;
}
.gridview.gridview-loader {
.gridview .gridview-loader {
display: none;
left: 50%;
position: absolute;
Expand Down
13 changes: 11 additions & 2 deletions mesoft.gridview/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using mesoft.gridview.Models;
using MT.GridView.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace mesoft.gridview.Controllers
namespace MT.GridView.Controllers
{
public class HomeController : Controller
{
Expand All @@ -21,6 +21,15 @@ public ActionResult GetCustomers(PagingInfo PagingData)
return PartialView("_CustomersPartial", model);
}

public PartialViewResult GetGridViewFilter()
{
using (var db = new MyDbContext())
{
var model = db.Customers.Select(x => x.Country).Distinct().ToList();
return PartialView("_GridViewFilterPartial",model);
}
}

public ActionResult About()
{
ViewBag.Message = "Your application description page.";
Expand Down
2 changes: 1 addition & 1 deletion mesoft.gridview/Global.asax
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%@ Application Codebehind="Global.asax.cs" Inherits="mesoft.gridview.MvcApplication" Language="C#" %>
<%@ Application Codebehind="Global.asax.cs" Inherits="MT.GridView.MvcApplication" Language="C#" %>
33 changes: 11 additions & 22 deletions mesoft.gridview/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using mesoft.gridview.Migrations;
using mesoft.gridview.Models;
using MT.GridView.Migrations;
using MT.GridView.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
Expand All @@ -8,8 +8,11 @@
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using System.IO;
using System.Runtime.Serialization.Json;
using Newtonsoft.Json;

namespace mesoft.gridview
namespace MT.GridView
{
public class MvcApplication : System.Web.HttpApplication
{
Expand All @@ -20,7 +23,7 @@ protected void Application_Start()
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);

Database.SetInitializer(new InitializeDB());
Database.SetInitializer(new InitializeDB());
}
}

Expand All @@ -29,25 +32,11 @@ public class InitializeDB : CreateDatabaseIfNotExists<MyDbContext>
protected override void Seed(MyDbContext context)
{
var customers = new List<Customer>();
string[] cities = { "Istanbul", "Trabzon", "Ankara", "Izmir", "Samsun", "Erzurum" };
DateTime[] dates = {new DateTime(1982, 5, 2), new DateTime(1983, 3, 5), new DateTime(1988,2,9), new DateTime(1999,12,1),new DateTime(2005,5,15),new DateTime(2010,01,01)};
var rnd = new Random(0);
for (int i = 0; i < 39; i++)
{

var cust = new Customer()
{
CompanyName = "Company Name " + i,
ContactTitle = "Contact Title " + i,
Country = "Turkey",
City = cities[rnd.Next(0, cities.Length - 1)],
Phone = "6564811215",
Address = "Address For Company " + i,
Founded = dates[rnd.Next(0, dates.Length-1)]
};
customers.Add(cust);
}
var path = AppDomain.CurrentDomain.BaseDirectory+ "MOCK_DATA.json";
var mockdata = File.ReadAllText(path);

customers = JsonConvert.DeserializeObject<List<Customer>>(mockdata, new JsonSerializerSettings() { DateFormatString = "dd/MM/yyyy"});

context.Customers.AddRange(customers.ToArray());
}
}
Expand Down
73 changes: 73 additions & 0 deletions mesoft.gridview/HtmlHelpers/GridviewHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Web.Mvc;

namespace MT.GridView.HtmlHelpers
{
public static class GridviewHelper
{
public static MvcHtmlString GridView(this HtmlHelper html, string readUrl, string gridName,
Func<MvcHtmlString> filterPartial = null)
{
var gridview = new TagBuilder("div");
var gridviewHeader = new TagBuilder("div");
var gridviewSearch = new TagBuilder("div");
var gridviewViewport = new TagBuilder("div");

gridview.InnerHtml = "<!--GRIDVIEW-->";
gridview.AddCssClass("gridview " + gridName);

//Grid Header
gridviewHeader.AddCssClass("gridview-header");
gridviewHeader.InnerHtml += @"<div class=""row""><div class=""col-sm-6"">";

gridviewSearch.AddCssClass("gridview-search");
gridviewSearch.InnerHtml = $@"<div class=""search input-group"">
<input class=""form-control"" placeholder=""Ara..."" type=""search"">
<span class=""input-group-btn"">
<button class=""btn btn-default"" type=""button"">
<span class=""fa fa-search""></span>
<span class=""sr-only"">Ara</span>
</button>
</span>
</div>";

gridviewHeader.InnerHtml+= gridviewSearch.ToString();

// Close col-sm-6
gridviewHeader.InnerHtml+= "</div>";

if (filterPartial != null)
{
gridviewHeader.InnerHtml += filterPartial.Invoke();
}
else
{
gridviewHeader.InnerHtml += @"<div class=""col-sm-6 text-right""></div>";
}

gridviewHeader.InnerHtml+="</div><!--End Of Row-->";
//End of GridView Header
gridview.InnerHtml += gridviewHeader;

//Gridview ViewPort
gridviewViewport.AddCssClass("gridview-viewport");
gridviewViewport.Attributes.Add("id", "viewport");
gridviewViewport.Attributes.Add("data-getdata-function", readUrl);
gridviewViewport.InnerHtml+= @"<div class=""gridview-canvas"" style=""min-height:400px;"">
</div>
<div class=""loading gridview-loader"">
<img src = ""/images/loading.gif"" />
</div>";
//End of GridView ViewPort
gridview.InnerHtml+= gridviewViewport.ToString();

//Gridview Footer
gridview.InnerHtml+= @"<div class=""gridview-footer"">
</div>";

gridview.InnerHtml += "<!-- /END OF GRIDVIEW-->";

return MvcHtmlString.Create(gridview.ToString());
}
}
}
Binary file added mesoft.gridview/Images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 387aaed

Please sign in to comment.