Skip to content

Commit

Permalink
Merge class from html attributes when rendering cell
Browse files Browse the repository at this point in the history
  • Loading branch information
jehhynes committed Jul 27, 2021
1 parent bba34e5 commit cd9593f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Griddly.NetCore.Razor/Pages/Shared/Griddly/Griddly.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,14 @@
@foreach (GriddlyColumn column in settings.Columns)
{
var underlyingValue = column.RenderUnderlyingValue(row, Html);
<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>
var htmlAttributes = column.GenerateHtmlAttributes(row, Model);
string additionalClassNames = null;
if (htmlAttributes?.ContainsKey("class") == true)
{
additionalClassNames = htmlAttributes["class"]?.ToString();
htmlAttributes.Remove("class");
}
<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>
}
</tr>
}
Expand Down
9 changes: 8 additions & 1 deletion Griddly/Views/Shared/Griddly/Griddly.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,14 @@
@foreach (GriddlyColumn column in settings.Columns)
{
var underlyingValue = column.RenderUnderlyingValue(row, Html);
<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>
var htmlAttributes = column.GenerateHtmlAttributes(row, Model);
string additionalClassNames = null;
if (htmlAttributes?.ContainsKey("class") == true)
{
additionalClassNames = htmlAttributes["class"]?.ToString();
htmlAttributes.Remove("class");
}
<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>
}
</tr>
}
Expand Down

0 comments on commit cd9593f

Please sign in to comment.