Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: 1kevgriff/Presentation-Grid-Magic
base: 05a57075ee
...
head fork: 1kevgriff/Presentation-Grid-Magic
compare: 8b6fdbbdbb
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
28 GridMagic/GridMagic.2_Server/Controllers/HomeController.cs
@@ -23,9 +23,15 @@ public ActionResult About()
public JsonResult GetAlbumList()
{
- int pageSize = Request.Params["paging[pageSize]"] != null ? Convert.ToInt32(Request.Params["paging[pageSize]"]) : 10;
+ int pageSize = Request.Params["paging[pageSize]"] != null ? Convert.ToInt32(Request.Params["paging[pageSize]"]) : 0;
int pageIndex = Request.Params["paging[pageIndex]"] != null ? Convert.ToInt32(Request.Params["paging[pageIndex]"]) : 0;
+ string sortColumn = Request.Params["sorting[0][dataKey]"];
+ string sortDirection = Request.Params["sorting[0][sortDirection]"];
+
+ if (string.IsNullOrEmpty(sortColumn)) sortColumn = String.Empty;
+ if (string.IsNullOrEmpty(sortDirection)) sortDirection = String.Empty;
+
using (var entity = new ChinookEntities())
{
var allAlbums = from al in entity.Albums
@@ -36,9 +42,21 @@ public JsonResult GetAlbumList()
ArtistName = ar.Name
};
- allAlbums = allAlbums.OrderBy(p=>p.AlbumName).Skip(pageSize*pageIndex).Take(pageSize);
+ var totalRowCount = allAlbums.Count();
+
+ if (pageSize == 0)
+ pageSize = totalRowCount;
+
+ if (sortColumn.ToLower() != "album")
+ allAlbums = sortDirection.ToLower() == "descending"
+ ? allAlbums.OrderByDescending(p => p.ArtistName).Skip(pageSize*pageIndex).Take(pageSize)
+ : allAlbums.OrderBy(p => p.ArtistName).Skip(pageSize*pageIndex).Take(pageSize);
+ else
+ allAlbums = sortDirection.ToLower() == "descending"
+ ? allAlbums.OrderByDescending(p => p.AlbumName).Skip(pageSize*pageIndex).Take(pageSize)
+ : allAlbums.OrderBy(p => p.AlbumName).Skip(pageSize*pageIndex).Take(pageSize);
- var result = new WijmoGridResult<AlbumResult> {rows = allAlbums.ToList(), totalRows = allAlbums.Count()};
+ var result = new WijmoGridResult<AlbumResult> { Items = allAlbums.ToList(), TotalRowCount = totalRowCount };
return Json(result, JsonRequestBehavior.AllowGet);
}
@@ -53,7 +71,7 @@ public class AlbumResult
public class WijmoGridResult<T>
{
- public List<T> rows { get; set; }
- public int totalRows { get; set; }
+ public List<T> Items { get; set; }
+ public int TotalRowCount { get; set; }
}
}
View
78 GridMagic/GridMagic.2_Server/Views/Home/Index.cshtml
@@ -1,29 +1,49 @@
-@{
- ViewBag.Title = "Home Page";
-}
-<table id="remoteTable">
-</table>
-<script type="text/javascript">
- $(document).ready(function () {
-
- var dataReader = new wijarrayreader([
- { name: "Artist", mapping: "ArtistName" },
- { name: "Album", mapping: "AlbumName" }
- ]);
-
- var dataSource = new wijdatasource({
- proxy: new wijhttpproxy({
- url: "@Url.Action("GetAlbumList")",
- dataType: "json"
- }),
- reader: dataReader
- });
-
- $("#remoteTable").wijgrid({
- data: dataSource,
- pageSize: 10,
- allowPaging: true
- });
- });
-
-</script>
+@{
+ ViewBag.Title = "Home Page";
+}
+<table id="remoteTable">
+</table>
+<script type="text/javascript">
+ $(document).ready(function () {
+
+ var dataReader = new wijarrayreader([
+ { name: "Artist", mapping: "ArtistName" },
+ { name: "Album", mapping: "AlbumName" }
+ ]);
+
+ var dataSource = new wijdatasource({
+ proxy: new wijhttpproxy({
+ url: "@Url.Action("GetAlbumList")",
+ dataType: "json"
+ }),
+ dynamic: true,
+ reader: {
+ read: function (datasource) {
+ var count = datasource.data.TotalRowCount;
+ datasource.data = datasource.data.Items;
+ datasource.data.totalRows = count;
+ dataReader.read(datasource);
+ }
+ }
+ });
+
+ $("#remoteTable").wijgrid({
+ pageSize: 15,
+ data: dataSource,
+ allowPaging: true,
+ allowSorting: true,
+ columns: [
+ {
+ aggregate: "count",
+ groupInfo: {
+ outlineMode: "startCollapsed",
+ headerText: "{2} :: {0}"
+ }
+ },
+ {
+ }
+ ]
+ });
+ });
+
+</script>
View
BIN  GridMagic/GridMagic.sln.docstates.suo
Binary file not shown
View
BIN  GridMagic/GridMagic.suo
Binary file not shown
View
213 Script.txt
@@ -0,0 +1,213 @@
+CLIENT SIDE
+-----------
+
+1) Create a new web application
+2) Copy into Layout
+
+ <!--jQuery References-->
+ <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.1.min.js" type="text/javascript"></script>
+ <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.17/jquery-ui.min.js" type="text/javascript"></script>
+ <!--Theme-->
+ <link href="http://cdn.wijmo.com/themes/rocket/jquery-wijmo.css" rel="stylesheet"
+ type="text/css" title="rocket-jqueryui" />
+ <!--Wijmo Widgets CSS-->
+ <link href="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.0.0b2.min.css" rel="stylesheet"
+ type="text/css" />
+ <!--Wijmo Widgets JavaScript-->
+ <script src="http://cdn.wijmo.com/jquery.wijmo-open.all.2.0.0b2.min.js" type="text/javascript"></script>
+ <script src="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.0.0b2.min.js" type="text/javascript"></script>
+
+3) Copy into Index.cshtml
+
+ <table id="tableDepartmentInformation">
+ <thead>
+ <tr>
+ <th>First Name
+ </th>
+ <th>Last Name</th>
+ <th>Department</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Kevin</td>
+ <td>Griffin</td>
+ <td>Marketing</td>
+ </tr>
+ <tr>
+ <td>Rich</td>
+ <td>Dudley</td>
+ <td>Marketing</td>
+ </tr>
+ <tr>
+ <td>Chris</td>
+ <td>Bannon</td>
+ <td>Development</td>
+ </tr>
+ <tr>
+ <td>Johnny</td>
+ <td>Doe</td>
+ <td>Management</td>
+ </tr>
+ <tr>
+ <td>Tommy</td>
+ <td>Tutone</td>
+ <td>IT</td>
+ </tr>
+ <tr>
+ <td>Joe</td>
+ <td>Montana</td>
+ <td>IT</td>
+ </tr>
+ <tr>
+ <td>Ingio</td>
+ <td>Montoya</td>
+ <td>Freelance</td>
+ </tr>
+ <tr>
+ <td>Luke</td>
+ <td>Skywalker</td>
+ <td>Jedi</td>
+ </tr>
+ </tbody>
+ </table>
+ <br/>
+ <button id="buttonApplyWijmo">Apply Wijmo</button>
+
+4) Apply a basic grid
+
+ $(document).ready(function () {
+ $("#buttonApplyWijmo").click(function () {
+ $("#tableDepartmentInformation").wijgrid();
+ });
+ });
+
+5) Apply Sorting
+ $("#tableDepartmentInformation").wijgrid(
+ {
+ allowSorting: true
+ });
+
+6) Apply Paging
+ {
+ allowPaging: true,
+ pageSize: 2
+ });
+
+7) Apply Filters
+ {
+ showFilter: true
+ }
+
+8) Apply Grouping
+ {
+ allowColMoving: true,
+ showGroupArea: true
+ }
+
+
+SERVER SIDE
+------------
+
+1) Add in Chinook model
+
+2) Create GetAlbumList
+
+ public JsonResult GetAlbumList()
+ {
+ using (var entity = new ChinookEntities())
+ {
+ var allAlbums = from al in entity.Albums
+ join ar in entity.Artists on al.ArtistId equals ar.ArtistId
+ select new AlbumResult()
+ {
+ AlbumName = al.Title,
+ ArtistName = ar.Name
+ };
+
+ var totalRowCount = allAlbums.Count();
+
+ var result = new WijmoGridResult<AlbumResult> { Items = allAlbums.ToList(), TotalRowCount = totalRowCount };
+
+ return Json(result, JsonRequestBehavior.AllowGet);
+ }
+ }
+
+3) Remove table and add to Index.html
+<table id="remoteTable">
+</table>
+<script type="text/javascript">
+ $(document).ready(function () {
+
+ var dataReader = new wijarrayreader([
+ { name: "Artist", mapping: "ArtistName" },
+ { name: "Album", mapping: "AlbumName" }
+ ]);
+
+ var dataSource = new wijdatasource({
+ proxy: new wijhttpproxy({
+ url: "@Url.Action("GetAlbumList")",
+ dataType: "json"
+ }),
+ dynamic: true,
+ reader: {
+ read: function (datasource) {
+ var count = datasource.data.TotalRowCount;
+ datasource.data = datasource.data.Items;
+ datasource.data.totalRows = count;
+ dataReader.read(datasource);
+ }
+ }
+ });
+
+ $("#remoteTable").wijgrid({
+ data: dataSource,
+ columns: [
+ {
+ aggregate: "count",
+ groupInfo: {
+ outlineMode: "startCollapsed",
+ headerText: "{2} :: {0}"
+ }
+ },{}
+ ]
+ });
+ });
+
+</script>
+
+4) Paging
+ int pageSize = Request.Params["paging[pageSize]"] != null ? Convert.ToInt32(Request.Params["paging[pageSize]"]) : 0;
+ int pageIndex = Request.Params["paging[pageIndex]"] != null ? Convert.ToInt32(Request.Params["paging[pageIndex]"]) : 0;
+
+ if (pageSize == 0)
+ pageSize = totalRowCount;
+
+ allAlbums = allAlbums.OrderBy(p => p.ArtistName).Skip(pageSize*pageIndex).Take(pageSize);
+
+5) Paging - JS
+
+ allowPaging: true,
+
+6) Sorting
+ string sortColumn = Request.Params["sorting[0][dataKey]"];
+ string sortDirection = Request.Params["sorting[0][sortDirection]"];
+
+ if (string.IsNullOrEmpty(sortColumn)) sortColumn = String.Empty;
+ if (string.IsNullOrEmpty(sortDirection)) sortDirection = String.Empty;
+
+ ----
+
+ if (sortColumn.ToLower() != "album")
+ allAlbums = sortDirection.ToLower() == "descending"
+ ? allAlbums.OrderByDescending(p => p.ArtistName).Skip(pageSize*pageIndex).Take(pageSize)
+ : allAlbums.OrderBy(p => p.ArtistName).Skip(pageSize*pageIndex).Take(pageSize);
+ else
+ allAlbums = sortDirection.ToLower() == "descending"
+ ? allAlbums.OrderByDescending(p => p.AlbumName).Skip(pageSize*pageIndex).Take(pageSize)
+ : allAlbums.OrderBy(p => p.AlbumName).Skip(pageSize*pageIndex).Take(pageSize);
+
+
+7) Sorting - JS
+
+ allowSorting: true,

No commit comments for this range

Something went wrong with that request. Please try again.