Skip to content

Commit d96c873

Browse files
committed
2 parents f01d3e9 + 05d7e48 commit d96c873

27 files changed

+3457
-2775
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.50.0")]
19-
[assembly: AssemblyFileVersion("1.0.50.0")]
18+
[assembly: AssemblyVersion("1.0.60.0")]
19+
[assembly: AssemblyFileVersion("1.0.70.0")]

Griddly.Mvc/GriddlyButton.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class GriddlyButton
1414
public bool IsSeparator { get; set; }
1515
public bool IsSplitDropdown { get; set; }
1616
public string Text { get; set; }
17+
public string Title { get; set; }
1718
public string Icon { get; set; }
1819
public string ClassName { get; set; }
1920
public string Target { get; set; }

Griddly.Mvc/GriddlyColumn.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ public override object RenderCellValue(object row, bool stripHtml = false)
135135
else if (value is Enum)
136136
value = Extensions.ToStringDescription((Enum)value);
137137
else if (value != null && value.GetType().HasCastOperator<DateTime>())
138-
value = (DateTime)value;
138+
// value = (DateTime)value; -- BAD: can't unbox a value type as a different type
139+
value = Convert.ChangeType(value, typeof(DateTime));
139140

140141
if (stripHtml && value is string)
141142
value = HttpUtility.HtmlDecode(_htmlMatch.Replace(value.ToString(), "").Trim().Replace(" ", " "));

Griddly.Mvc/GriddlyExtensions.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ public static void SetGriddlyDefault<T>(this Controller controller, ref T parame
108108
controller.ViewData["_griddlyDefault_" + field] = value;
109109
}
110110

111+
public static void SetGriddlyDefault<T>(this Controller controller, ref T[] parameter, string field, IEnumerable<T> value)
112+
{
113+
if (controller.ControllerContext.IsChildAction)
114+
parameter = value.ToArray();
115+
116+
controller.ViewData["_griddlyDefault_" + field] = value;
117+
}
118+
119+
public static void SetGriddlyDefault<T>(this Controller controller, ref T?[] parameter, string field, IEnumerable<T> value)
120+
where T: struct
121+
{
122+
if (controller.ControllerContext.IsChildAction)
123+
parameter = value.Cast<T?>().ToArray();
124+
125+
controller.ViewData["_griddlyDefault_" + field] = value;
126+
}
127+
111128
public static object GetGriddlyDefault(this WebViewPage page, string field)
112129
{
113130
return page.ViewData["_griddlyDefault_" + field];
@@ -136,7 +153,9 @@ public static string Current(this UrlHelper helper, object routeValues = null, b
136153
if (t.IsPrimitive || t.IsEnum || t == typeof(Decimal) || t == typeof(String) || t == typeof(DateTime) || t == typeof(TimeSpan) || t == typeof(DateTimeOffset))
137154
values[value.Key] = value.Value;
138155
else if (t.HasCastOperator<DateTime>())
139-
values[value.Key] = (DateTime)value.Value;
156+
// values[value.Key] = (DateTime)value.Value; -- BAD: can't unbox a value type as a different type
157+
values[value.Key] = Convert.ChangeType(value.Value, typeof(DateTime));
158+
140159
}
141160
}
142161

@@ -157,7 +176,8 @@ public static string Current(this UrlHelper helper, object routeValues = null, b
157176
if (t.IsPrimitive || t.IsEnum || t == typeof(Decimal) || t == typeof(String) || t == typeof(DateTime) || t == typeof(TimeSpan) || t == typeof(DateTimeOffset))
158177
values[value.Key] = value.Value;
159178
else if (t.HasCastOperator<DateTime>())
160-
values[value.Key] = (DateTime)value.Value;
179+
// values[value.Key] = (DateTime)value.Value; -- BAD: can't unbox a value type as a different type
180+
values[value.Key] = Convert.ChangeType(value.Value, typeof(DateTime));
161181
}
162182
}
163183
}

Griddly.Mvc/GriddlyFilterExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static string GetField(GriddlyColumn column)
111111
public static GriddlyFilterList FilterEnum<T>(this GriddlyColumn column, bool isMultiple = true, bool defaultSelectAll = true, string nullItemText = null, bool isNoneAll = true, string field = null, string caption = null)
112112
where T : struct
113113
{
114-
return column.FilterList(Extensions.ToSelectListItems<T>(), isMultiple, defaultSelectAll, nullItemText, isNoneAll, field, caption);
114+
return column.FilterList(Extensions.ToSelectListItems<T>().OrderBy(x => x.Text), isMultiple, defaultSelectAll, nullItemText, isNoneAll, field, caption);
115115
}
116116

117117
public static GriddlyFilterList FilterBool(this GriddlyColumn column, string trueLabel = "Yes", string falseLabel = "No", string nullItemText = null, bool isMultiple = false, bool defaultSelectAll = false, bool isNoneAll = false, string field = null, string caption = null)

Griddly.Mvc/GriddlyResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public override void ExecuteResult(ControllerContext context)
8686

8787
// TODO: should we always pull sort fields?
8888
if (!sortFields.Any())
89-
sortFields = settings.GetDefaultSort();
89+
sortFields = settings.DefaultSort;
9090

9191
if (settings.PageSize > settings.MaxPageSize)
9292
settings.PageSize = settings.MaxPageSize;

Griddly.Mvc/GriddlySettings.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,23 @@ public GriddlySettings SelectColumn(Func<object, object> id)
177177
});
178178
}
179179

180-
public SortField[] GetDefaultSort()
180+
SortField[] _defaultSort;
181+
182+
public SortField[] DefaultSort
181183
{
182-
return Columns
183-
.Where(x => x.DefaultSort != null)
184-
.Select(x => new SortField() { Field = x.SortField, Direction = x.DefaultSort.Value }).ToArray();
184+
get
185+
{
186+
if (_defaultSort == null)
187+
_defaultSort = Columns
188+
.Where(x => x.DefaultSort != null)
189+
.Select(x => new SortField() { Field = x.SortField, Direction = x.DefaultSort.Value }).ToArray();
190+
191+
return _defaultSort;
192+
}
193+
set
194+
{
195+
_defaultSort = value;
196+
}
185197
}
186198
}
187199

Griddly.Mvc/GriddlySettingsResult.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,12 @@ public static GriddlySettings GetSettings(ControllerContext context, string view
5757

5858
return settingsResult.Settings;
5959
}
60-
catch (HttpCompileException)
60+
catch (HttpException)
6161
{
6262
throw;
6363
}
64-
catch (Exception ex)
64+
catch
6565
{
66-
// TODO: throw exception if it is bad like HttpCompileException
6766
return null;
6867
}
6968
}
@@ -175,6 +174,14 @@ public override NameValueCollection ServerVariables
175174
return _serverVariables;
176175
}
177176
}
177+
178+
public override Uri Url
179+
{
180+
get
181+
{
182+
return new Uri("http://localhost/");
183+
}
184+
}
178185
}
179186

180187
class EmptyHttpResponse : HttpResponseBase

0 commit comments

Comments
 (0)