mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-02-14 05:36:00 +00:00
Fix customizing style of in HeaderCellRender and FooterCellRender (#1102)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
@typeparam TItem
|
||||
@if (RowIndex == Column.GetLevel())
|
||||
{
|
||||
<td rowspan="@(Column.GetRowSpan())" colspan="@(Column.GetColSpan())" @attributes="@Attributes" class="@CssClass" scope="col" style="@Column.GetStyle(true, true)">
|
||||
<td rowspan="@(Column.GetRowSpan())" colspan="@(Column.GetColSpan())" @attributes="@Attributes" class="@CssClass" scope="col" style="@GetStyle()">
|
||||
<span class="rz-column-footer">
|
||||
@if (Column.FooterTemplate != null)
|
||||
{
|
||||
@@ -14,7 +14,7 @@ else
|
||||
{
|
||||
@foreach(var column in Grid.childColumns.Where(c => c.GetVisible() && c.Parent == Column))
|
||||
{
|
||||
<RadzenDataGridFooterCell RowIndex="@RowIndex" Grid="@Grid" Column="@column"
|
||||
<RadzenDataGridFooterCell RowIndex="@RowIndex" Grid="@Grid" Column="@column" Style="@column.GetStyle(true, true)"
|
||||
CssClass="@($"{Column.FooterCssClass} {Grid.getFrozenColumnClass(column, Grid.ColumnsCollection.Where(c => c.GetVisible()).ToList())} {Grid.getCompositeCellCSSClass(column)}")"
|
||||
Attributes="@(Attributes)" />
|
||||
}
|
||||
@@ -34,4 +34,17 @@ else
|
||||
|
||||
[Parameter]
|
||||
public string CssClass { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Style { get; set; }
|
||||
|
||||
string GetStyle()
|
||||
{
|
||||
if (Attributes != null && Attributes.TryGetValue("style", out var style) == true && !string.IsNullOrEmpty(Convert.ToString(style)))
|
||||
{
|
||||
return String.IsNullOrEmpty(Style) ? $"{style}" : $"{Style.TrimEnd(';')};{style}";
|
||||
}
|
||||
|
||||
return Style;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
@using Radzen.Blazor.Rendering
|
||||
@if (RowIndex == Column.GetLevel())
|
||||
{
|
||||
<th rowspan="@(Column.GetRowSpan())" colspan="@(Column.GetColSpan())" @attributes="@Attributes" class="@CssClass" scope="col" style="@Column.GetStyle(true, true)" @onmouseup=@(args => Grid.EndColumnReorder(args, ColumnIndex)) >
|
||||
<th rowspan="@(Column.GetRowSpan())" colspan="@(Column.GetColSpan())" @attributes="@Attributes" class="@CssClass" scope="col" style="@GetStyle()" @onmouseup=@(args => Grid.EndColumnReorder(args, ColumnIndex))>
|
||||
<div @onclick='@((args) => Grid.OnSort(args, Column))' tabindex="@SortingTabIndex" @onkeydown="OnSortKeyPressed">
|
||||
@if ((Grid.AllowColumnReorder && Column.Reorderable || Grid.AllowGrouping && Column.Groupable))
|
||||
{
|
||||
@@ -152,7 +152,7 @@ else
|
||||
{
|
||||
ColumnIndex = Grid.allColumns.IndexOf(column);//for child must have different columnindex
|
||||
|
||||
<RadzenDataGridHeaderCell RowIndex="@RowIndex" Grid="@Grid" Column="@column" ColumnIndex="@ColumnIndex"
|
||||
<RadzenDataGridHeaderCell RowIndex="@RowIndex" Grid="@Grid" Column="@column" Style="@column.GetStyle(true, true)" ColumnIndex="@ColumnIndex"
|
||||
CssClass="@($" maitest rz-unselectable-text {(Grid.AllowSorting && column.Sortable ? "rz-sortable-column" : "")} {column.HeaderCssClass} {Grid.getFrozenColumnClass(column, Grid.ColumnsCollection.Where(c => c.GetVisible()).ToList())} {Grid.getCompositeCellCSSClass(column)} {Grid.getColumnAlignClass(column)}".Trim())" />
|
||||
}
|
||||
}
|
||||
@@ -209,6 +209,19 @@ else
|
||||
[Parameter]
|
||||
public string CssClass { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Style { get; set; }
|
||||
|
||||
string GetStyle()
|
||||
{
|
||||
if (Attributes != null && Attributes.TryGetValue("style", out var style) == true && !string.IsNullOrEmpty(Convert.ToString(style)))
|
||||
{
|
||||
return String.IsNullOrEmpty(Style) ? $"{style}" : $"{Style.TrimEnd(';')};{style}";
|
||||
}
|
||||
|
||||
return Style;
|
||||
}
|
||||
|
||||
private int SortingTabIndex => Grid.AllowSorting && Column.Sortable ? 0 : -1;
|
||||
|
||||
private string getFilterIconCss(RadzenDataGridColumn<TItem> column)
|
||||
|
||||
Reference in New Issue
Block a user