Skip to content

Commit 13be9e9

Browse files
committed
Add space for range start/range end default render on Griddly.cshtml
Add support for enum and datetime convertible to Url.Current helper
1 parent 2e333c2 commit 13be9e9

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("1.0.49.0")]
19-
[assembly: AssemblyFileVersion("1.0.49.0")]
18+
[assembly: AssemblyVersion("1.0.50.0")]
19+
[assembly: AssemblyFileVersion("1.0.50.0")]

Griddly.Mvc/GriddlyExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ public static string Current(this UrlHelper helper, object routeValues = null, b
133133
{
134134
Type t = value.Value.GetType();
135135

136-
if (t.IsPrimitive || t == typeof(Decimal) || t == typeof(String) || t == typeof(DateTime) || t == typeof(TimeSpan) || t == typeof(DateTimeOffset))
136+
if (t.IsPrimitive || t.IsEnum || t == typeof(Decimal) || t == typeof(String) || t == typeof(DateTime) || t == typeof(TimeSpan) || t == typeof(DateTimeOffset))
137137
values[value.Key] = value.Value;
138+
else if (t.HasCastOperator<DateTime>())
139+
values[value.Key] = (DateTime)value.Value;
138140
}
139141
}
140142

@@ -152,8 +154,10 @@ public static string Current(this UrlHelper helper, object routeValues = null, b
152154
{
153155
Type t = value.Value.GetType();
154156

155-
if (t.IsPrimitive || t == typeof(Decimal) || t == typeof(String) || t == typeof(DateTime) || t == typeof(TimeSpan) || t == typeof(DateTimeOffset))
157+
if (t.IsPrimitive || t.IsEnum || t == typeof(Decimal) || t == typeof(String) || t == typeof(DateTime) || t == typeof(TimeSpan) || t == typeof(DateTimeOffset))
156158
values[value.Key] = value.Value;
159+
else if (t.HasCastOperator<DateTime>())
160+
values[value.Key] = (DateTime)value.Value;
157161
}
158162
}
159163
}

Griddly/Controllers/HomeController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public GriddlyResult TestGrid(string firstName, int? zipStart, int? zipEnd)
3232
return new GriddlyResult<TestGridItem>(query);
3333
}
3434

35-
public GriddlyResult FilterBoxGrid(string lastName)
35+
public GriddlyResult FilterBoxGrid(string lastName, DateTime? city)
3636
{
3737
this.SetGriddlyDefault(ref lastName, "lastName", "ba");
3838

@@ -54,8 +54,10 @@ public GriddlyResult FilterBoxGrid(string lastName)
5454
return new GriddlyResult<TestGridItem>(query);
5555
}
5656

57-
public GriddlyResult FilterRangeGrid()
57+
public GriddlyResult FilterRangeGrid(DateTime? stateStart)
5858
{
59+
this.SetGriddlyDefault(ref stateStart, "stateStart", DateTime.Now);
60+
5961
IQueryable<TestGridItem> query = _testData;
6062

6163
//if (!string.IsNullOrWhiteSpace(firstName))

Griddly/Views/Home/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<div class="row">
1313
<div class="col-md-12">
14-
@Html.Griddly("FilterBoxGrid")
14+
@Html.Griddly("FilterBoxGrid", new { test = SortDirection.Ascending })
1515
@Html.Griddly("FilterRangeGrid")
1616
@Html.Griddly("FilterListGrid")
1717
@Html.Griddly("TestGrid")

Griddly/Views/Shared/Griddly/Griddly.cshtml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,11 @@
222222
}
223223
else if (defaultValue != null)
224224
{
225-
@(filter.DataType == FilterDataType.Date ? "After" : ">=")
226-
@filter.GetFormattedValue(defaultValue)
225+
<text>@(filter.DataType == FilterDataType.Date ? "After" : ">=") @filter.GetFormattedValue(defaultValue)</text>
227226
}
228227
else if (defaultValueEnd != null)
229228
{
230-
@(filter.DataType == FilterDataType.Date ? "Before" : "<=")
231-
@filter.GetFormattedValue(defaultValueEnd)
229+
<text>@(filter.DataType == FilterDataType.Date ? "Before" : "<=") @filter.GetFormattedValue(defaultValueEnd)</text>
232230
}
233231
else
234232
{

0 commit comments

Comments
 (0)