Skip to content

Commit c13c65e

Browse files
committed
Made default sort settable
1 parent f33854f commit c13c65e

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
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.58.0")]
19-
[assembly: AssemblyFileVersion("1.0.58.0")]
18+
[assembly: AssemblyVersion("1.0.59.0")]
19+
[assembly: AssemblyFileVersion("1.0.59.0")]

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

0 commit comments

Comments
 (0)