Skip to content

Commit cd9593f

Browse files
committed
Merge class from html attributes when rendering cell
1 parent bba34e5 commit cd9593f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,14 @@
317317
@foreach (GriddlyColumn column in settings.Columns)
318318
{
319319
var underlyingValue = column.RenderUnderlyingValue(row, Html);
320-
<td class="@column.RenderClassName(row, Model) @(!column.Visible ? "column-hidden" : null)" @column.GenerateHtmlAttributes(row, Model).ToHtmlAttributes() @if (underlyingValue != null) { <text> data-value="@underlyingValue" </text> }>@column.RenderCell(row, settings, Html)</td>
320+
var htmlAttributes = column.GenerateHtmlAttributes(row, Model);
321+
string additionalClassNames = null;
322+
if (htmlAttributes?.ContainsKey("class") == true)
323+
{
324+
additionalClassNames = htmlAttributes["class"]?.ToString();
325+
htmlAttributes.Remove("class");
326+
}
327+
<td class="@column.RenderClassName(row, Model) @(!column.Visible ? "column-hidden" : null) @additionalClassNames" @htmlAttributes.ToHtmlAttributes() @if (underlyingValue != null) { <text> data-value="@underlyingValue" </text> }>@column.RenderCell(row, settings, Html)</td>
321328
}
322329
</tr>
323330
}

Griddly/Views/Shared/Griddly/Griddly.cshtml

+8-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,14 @@
304304
@foreach (GriddlyColumn column in settings.Columns)
305305
{
306306
var underlyingValue = column.RenderUnderlyingValue(row, Html);
307-
<td class="@column.RenderClassName(row, Model) @(!column.Visible ? "column-hidden" : null)" @column.GenerateHtmlAttributes(row, Model).ToHtmlAttributes() @if (underlyingValue != null) { <text>data-value="@underlyingValue"</text> }>@column.RenderCell(row, settings, Html)</td>
307+
var htmlAttributes = column.GenerateHtmlAttributes(row, Model);
308+
string additionalClassNames = null;
309+
if (htmlAttributes?.ContainsKey("class") == true)
310+
{
311+
additionalClassNames = htmlAttributes["class"]?.ToString();
312+
htmlAttributes.Remove("class");
313+
}
314+
<td class="@column.RenderClassName(row, Model) @(!column.Visible ? "column-hidden" : null) @additionalClassNames" @htmlAttributes.ToHtmlAttributes() @if (underlyingValue != null) { <text> data-value="@underlyingValue" </text> }>@column.RenderCell(row, settings, Html)</td>
308315
}
309316
</tr>
310317
}

0 commit comments

Comments
 (0)