Skip to content

Grid identifier #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Build/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.InteropServices;

[assembly: AssemblyProduct("Griddly")]
[assembly: AssemblyCopyright("Copyright © 2013-2023 Chris Hynes, Joel Potter, and Data Research Group")]
[assembly: AssemblyCopyright("Copyright © 2013-2024 Chris Hynes, Joel Potter, and Data Research Group")]

[assembly: ComVisible(false)]

Expand All @@ -15,6 +15,6 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.6.39")]
[assembly: AssemblyFileVersion("3.6.39")]
[assembly: AssemblyVersion("3.6.40")]
[assembly: AssemblyFileVersion("3.6.40")]
//[assembly: AssemblyInformationalVersion("2.5-filters")]
19 changes: 15 additions & 4 deletions Griddly.Mvc/GriddlyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,23 @@ private static GriddlyContext GetOrCreateGriddlyContext(RouteData routeData, Htt

sortFields = GriddlyResult.GetSortFields(items);

#if NETFRAMEWORK
string cookieSuffix = (controller.ControllerContext.RouteData.Values["GridIdentifier"] as string);
#else
string cookieSuffix = (routeData.Values["GridIdentifier"] as string);
#endif

if (string.IsNullOrEmpty(cookieSuffix))
cookieSuffix = items["GridIdentifier"];

cookieSuffix = !string.IsNullOrEmpty(cookieSuffix) ? "_" + cookieSuffix.ToLower() : string.Empty;
Comment on lines +533 to +542
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, but I think we should use a short querystring param name. Maybe gid or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to understand what is driving factor of reaming it to gid? I prefer long variable name so that it convey the usage without extra details (It could be just me) please advice.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually I would too, but since this is part of the route data which is transmitted in the URL I prefer short.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have raised the new PR: #125 for all these changes


context = new GriddlyContext()
{
#if NETFRAMEWORK
Name = (controller.GetType().Name + "_" + controller.ControllerContext.RouteData.Values["action"] as string).ToLower(),
Name = (controller.GetType().Name + "_" + controller.ControllerContext.RouteData.Values["action"] as string).ToLower() + cookieSuffix,
#else
Name = (routeData.Values["controller"] as string).ToLower() + "_" + (routeData.Values["action"] as string).ToLower(),
Name = (routeData.Values["controller"] as string).ToLower() + "_" + (routeData.Values["action"] as string).ToLower() + cookieSuffix,
#endif
PageNumber = pageNumber,
PageSize = pageSize,
Expand Down Expand Up @@ -622,7 +633,7 @@ public static string Current(this IUrlHelper helper, ViewContext vc, object rout
{
if (arrayVals.Length > 0)
arrayVals.Append("&");
arrayVals.Append(string.Join("&", ((IEnumerable)value.Value).Cast<object>().Select(x=> value.Key + "=" + x?.ToString())));
arrayVals.Append(string.Join("&", ((IEnumerable)value.Value).Cast<object>().Select(x => value.Key + "=" + x?.ToString())));
}
}
}
Expand Down Expand Up @@ -656,7 +667,7 @@ public static string Current(this IUrlHelper helper, ViewContext vc, object rout
}

var route = helper.RouteUrl(values);
if(arrayVals.Length>0)
if (arrayVals.Length > 0)
{
route += (route.Contains("?") ? "&" : "?") + arrayVals.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyButton renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyButton button strip renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Griddly.NetCore.Razor/Pages/Shared/Griddly/Griddly.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* Griddly renderer
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilterBar renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilter form renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilter inline renderer
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilter value renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilters section renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
27 changes: 15 additions & 12 deletions Griddly.NetCore.Razor/wwwroot/js/griddly.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Griddly script
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down Expand Up @@ -1065,10 +1065,7 @@
}
}

setRowSelect($checkbox);

if (event.shiftKey && this.options.lastSelectedRow)
{
if (event.shiftKey && this.options.lastSelectedRow) {
var last = $("tbody tr", this.$element).index(this.options.lastSelectedRow);
var first = $("tbody tr", this.$element).index($target.parents("tr"));
var newstate = this.options.lastSelectedRow.find("input[name=_rowselect]").prop("checked");
Expand All @@ -1077,19 +1074,23 @@
var end = Math.max(first, last);

$("tbody tr", this.$element).slice(start, end).find("input[name=_rowselect]").each(function () { $(this).prop("checked", newstate); setRowSelect($(this), true) });
setRowSelect($checkbox);

onRowChange();
}
else {
setRowSelect($checkbox);
}

this.options.lastSelectedRow = $target.parents("tr");
}, this));

$(this.$element).on("click", "thead tr.columnHeaders th.select", $.proxy(function (event)
{
if (this.$element.find("input[name=_rowselect]:not(:checked)").length == 0)
this.$element.find("input[name=_rowselect]").prop("checked", false).each(function () { setRowSelect($(this), true); });
if (this.$element.find("input[name=_rowselect]:not(:checked):not(:disabled)").length == 0)
this.$element.find("input[name=_rowselect]:not(:disabled)").prop("checked", false).each(function () { setRowSelect($(this), true); });
else
this.$element.find("input[name=_rowselect]").prop("checked", true).each(function () { setRowSelect($(this), true); });
this.$element.find("input[name=_rowselect]:not(:disabled)").prop("checked", true).each(function () { setRowSelect($(this), true); });

onRowChange();
}, this));
Expand All @@ -1106,17 +1107,17 @@
}, this));
$("a.export-xlsx", this.$element).on("click", $.proxy(function (e)
{
this.exportFile("xlsx", null, { exportName: $(e.target).data("export-name") });
this.exportFile("xlsx", this.options.exportFunction, { exportName: $(e.target).data("export-name") });
e.preventDefault();
}, this));
$("a.export-csv", this.$element).on("click", $.proxy(function (e)
{
this.exportFile("csv", null, { exportName: $(e.target).data("export-name") });
this.exportFile("csv", this.options.exportFunction, { exportName: $(e.target).data("export-name") });
e.preventDefault();
}, this));
$("a.export-tsv", this.$element).on("click", $.proxy(function (e)
{
this.exportFile("tsv", null, { exportName: $(e.target).data("export-name") });
this.exportFile("tsv", this.options.exportFunction, { exportName: $(e.target).data("export-name") });
e.preventDefault();
}, this));

Expand Down Expand Up @@ -2044,7 +2045,9 @@
confirmPromptFunction: null,
renderFilterDisplay: renderFilterDisplayImpl,
serializeSkipEmpty: true,
filtersSelector: "input[name], select[name]"
filtersSelector: "input[name], select[name]",
exportCustomFunction: null,
exportFunction: null
}, $.fn.griddlyGlobalDefaults);

var GriddlyFilterBar = function (element, options)
Expand Down
10 changes: 7 additions & 3 deletions Griddly.NetCore/Views/Home/MultipleDefaultTest.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
<div class="col-md-12">
<h2>Multiple Default Test</h2>
<h3>Grid 1</h3>
@await Html.GriddlyAsync("Test1Grid")
<h3>Grid 2</h3>
@await Html.GriddlyAsync("Test2Grid")
@await Html.GriddlyAsync("Test1Grid", new { GridIdentifier = "Original" })
<h3>Copy Grid 1</h3>
@await Html.GriddlyAsync("Test1Grid", new { GridIdentifier = "Copy" })
<h3>Original Grid 2</h3>
@await Html.GriddlyAsync("Test2Grid", new { GridIdentifier = "Original" })
<h3>Copy Grid 2</h3>
@await Html.GriddlyAsync("Test2Grid", new { GridIdentifier = "Copy" })
</div>
</div>
27 changes: 15 additions & 12 deletions Griddly/Scripts/griddly.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Griddly script
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down Expand Up @@ -1065,10 +1065,7 @@
}
}

setRowSelect($checkbox);

if (event.shiftKey && this.options.lastSelectedRow)
{
if (event.shiftKey && this.options.lastSelectedRow) {
var last = $("tbody tr", this.$element).index(this.options.lastSelectedRow);
var first = $("tbody tr", this.$element).index($target.parents("tr"));
var newstate = this.options.lastSelectedRow.find("input[name=_rowselect]").prop("checked");
Expand All @@ -1077,19 +1074,23 @@
var end = Math.max(first, last);

$("tbody tr", this.$element).slice(start, end).find("input[name=_rowselect]").each(function () { $(this).prop("checked", newstate); setRowSelect($(this), true) });
setRowSelect($checkbox);

onRowChange();
}
else {
setRowSelect($checkbox);
}

this.options.lastSelectedRow = $target.parents("tr");
}, this));

$(this.$element).on("click", "thead tr.columnHeaders th.select", $.proxy(function (event)
{
if (this.$element.find("input[name=_rowselect]:not(:checked)").length == 0)
this.$element.find("input[name=_rowselect]").prop("checked", false).each(function () { setRowSelect($(this), true); });
if (this.$element.find("input[name=_rowselect]:not(:checked):not(:disabled)").length == 0)
this.$element.find("input[name=_rowselect]:not(:disabled)").prop("checked", false).each(function () { setRowSelect($(this), true); });
else
this.$element.find("input[name=_rowselect]").prop("checked", true).each(function () { setRowSelect($(this), true); });
this.$element.find("input[name=_rowselect]:not(:disabled)").prop("checked", true).each(function () { setRowSelect($(this), true); });

onRowChange();
}, this));
Expand All @@ -1106,17 +1107,17 @@
}, this));
$("a.export-xlsx", this.$element).on("click", $.proxy(function (e)
{
this.exportFile("xlsx", null, { exportName: $(e.target).data("export-name") });
this.exportFile("xlsx", this.options.exportFunction, { exportName: $(e.target).data("export-name") });
e.preventDefault();
}, this));
$("a.export-csv", this.$element).on("click", $.proxy(function (e)
{
this.exportFile("csv", null, { exportName: $(e.target).data("export-name") });
this.exportFile("csv", this.options.exportFunction, { exportName: $(e.target).data("export-name") });
e.preventDefault();
}, this));
$("a.export-tsv", this.$element).on("click", $.proxy(function (e)
{
this.exportFile("tsv", null, { exportName: $(e.target).data("export-name") });
this.exportFile("tsv", this.options.exportFunction, { exportName: $(e.target).data("export-name") });
e.preventDefault();
}, this));

Expand Down Expand Up @@ -2044,7 +2045,9 @@
confirmPromptFunction: null,
renderFilterDisplay: renderFilterDisplayImpl,
serializeSkipEmpty: true,
filtersSelector: "input[name], select[name]"
filtersSelector: "input[name], select[name]",
exportCustomFunction: null,
exportFunction: null
}, $.fn.griddlyGlobalDefaults);

var GriddlyFilterBar = function (element, options)
Expand Down
10 changes: 7 additions & 3 deletions Griddly/Views/Home/MultipleDefaultTest.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
<div class="col-md-12">
<h2>Multiple Default Test</h2>
<h3>Grid 1</h3>
@Html.Griddly("Test1Grid")
<h3>Grid 2</h3>
@Html.Griddly("Test2Grid")
@Html.Griddly("Test1Grid", new { GridIdentifier = "Original" })
<h3>Copy Grid 1</h3>
@Html.Griddly("Test1Grid", new { GridIdentifier = "Copy" })
<h3>Original Grid 2</h3>
@Html.Griddly("Test2Grid", new { GridIdentifier = "Original" })
<h3>Copy Grid 2</h3>
@Html.Griddly("Test2Grid", new { GridIdentifier = "Copy" })
</div>
</div>
2 changes: 1 addition & 1 deletion Griddly/Views/Shared/Griddly/BootstrapButton.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyButton renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Griddly/Views/Shared/Griddly/ButtonStrip.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyButton button strip renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Griddly/Views/Shared/Griddly/Griddly.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* Griddly renderer
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Griddly/Views/Shared/Griddly/GriddlyFilterBar.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilterBar renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Griddly/Views/Shared/Griddly/GriddlyFilterForm.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilter form renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Griddly/Views/Shared/Griddly/GriddlyFilterInline.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilter inline renderer
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Griddly/Views/Shared/Griddly/GriddlyFilterValues.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilter value renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Griddly/Views/Shared/Griddly/GriddlyFilters.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@*
* GriddlyFilters section renderer using Bootstrap html and styles
* http://griddly.com
* Copyright 2013-2023 Chris Hynes and Data Research Group, Inc.
* Copyright 2013-2024 Chris Hynes and Data Research Group, Inc.
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
*
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
Expand Down