Skip to content

Commit ceb4f6e

Browse files
committed
Resolve ColumnId on render instead of in the constructor
1 parent 87e110a commit ceb4f6e

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
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("3.7.6")]
19-
[assembly: AssemblyFileVersion("3.7.6")]
18+
[assembly: AssemblyVersion("3.7.7")]
19+
[assembly: AssemblyFileVersion("3.7.7")]
2020
//[assembly: AssemblyInformationalVersion("2.5-filters")]

Griddly.Mvc/GriddlyColumn.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ public GriddlyColumn(LambdaExpression expression, string caption, string columnI
2020
{
2121
Expression = expression;
2222
Caption = caption;
23-
24-
ColumnId = columnId != null ? columnId
25-
: expression != null ? GetIdFromExpression(expression)
26-
: !string.IsNullOrEmpty(ExpressionString) ? ExpressionString
27-
: Caption;
23+
ColumnId = columnId;
2824
}
2925

3026
string GetIdFromExpression(LambdaExpression expression)
@@ -51,7 +47,15 @@ string GetIdFromExpression(LambdaExpression expression)
5147
public double? ExportWidth { get; set; }
5248
public ColumnRenderMode RenderMode { get; set; }
5349
public bool Visible { get; set; } = true;
54-
public string ColumnId { get; set; }
50+
protected string ColumnId;
51+
52+
public string GetColumnId()
53+
{
54+
return ColumnId != null ? ColumnId
55+
: !string.IsNullOrEmpty(ExpressionString) ? ExpressionString
56+
: Caption;
57+
}
58+
5559
public SummaryAggregateFunction? SummaryFunction { get; set; }
5660
public object SummaryValue { get; set; }
5761
public IDictionary<string, object> HeaderHtmlAttributes { get; set; }

Griddly.NetCore.Razor/Pages/Shared/Griddly/Griddly.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
<colgroup>
218218
@foreach (GriddlyColumn column in settings.Columns)
219219
{
220-
<col @Html.AttributeIf("style", column.Width != null, "width:" + column.Width) data-field="@Griddly.Mvc.GriddlyFilterExtensions.GetField(column)" @Html.AttributeNullable("data-columnid", column.ColumnId) @Html.AttributeIf("class", !column.Visible, "column-hidden") />
220+
<col @Html.AttributeIf("style", column.Width != null, "width:" + column.Width) data-field="@Griddly.Mvc.GriddlyFilterExtensions.GetField(column)" @Html.AttributeNullable("data-columnid", column.GetColumnId()) @Html.AttributeIf("class", !column.Visible, "column-hidden") />
221221
}
222222
</colgroup>
223223
<thead>

Griddly/Views/Shared/Griddly/Griddly.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
<colgroup>
226226
@foreach (GriddlyColumn column in settings.Columns)
227227
{
228-
<col @Html.AttributeIf("style", column.Width != null, "width:" + column.Width) data-field="@Griddly.Mvc.GriddlyFilterExtensions.GetField(column)" @Html.AttributeNullable("data-columnid", column.ColumnId) @Html.AttributeIf("class", !column.Visible, "column-hidden") />
228+
<col @Html.AttributeIf("style", column.Width != null, "width:" + column.Width) data-field="@Griddly.Mvc.GriddlyFilterExtensions.GetField(column)" @Html.AttributeNullable("data-columnid", column.GetColumnId()) @Html.AttributeIf("class", !column.Visible, "column-hidden") />
229229
}
230230
</colgroup>
231231
<thead>

0 commit comments

Comments
 (0)