J.BE
J.BE
CC#
Created by J.BE on 5/9/2023 in #help
❔ Bug in blazor?
that blazor is trash
10 replies
CC#
Created by J.BE on 5/9/2023 in #help
❔ Bug in blazor?
because the data is correctly generated, thats why the tables are filled up, its the "totalrow" that gets the values from the specified columns, this is just calculated.
TotalRow:
public void Correct()
{
foreach (var index in OfColumns)
{
ColumnValues[index] = 0;
ColumnValues[index] = ParentComponent?
.Rows
.Sum(r => ((r as Row)?.Cells[index] as DecimalCell)?.Value ?? 0)
?? 0;
}
}
TotalRow:
public void Correct()
{
foreach (var index in OfColumns)
{
ColumnValues[index] = 0;
ColumnValues[index] = ParentComponent?
.Rows
.Sum(r => ((r as Row)?.Cells[index] as DecimalCell)?.Value ?? 0)
?? 0;
}
}
ParentComponent Table:
public void OnChildrenRendered()
{
foreach (var baseRow in Rows.FindAll(r => r is Row))
{
var row = (Row)baseRow;
if (RenderedRows.Contains(row)) continue;
Rows.Remove(row);
}
RenderedRows.Clear();
CorrectTotalRow();
StateHasChanged();
}

public void CorrectTotalRow()
{
((TotalRow?)Rows.Find(r => r is TotalRow))?.Correct();
}
ParentComponent Table:
public void OnChildrenRendered()
{
foreach (var baseRow in Rows.FindAll(r => r is Row))
{
var row = (Row)baseRow;
if (RenderedRows.Contains(row)) continue;
Rows.Remove(row);
}
RenderedRows.Clear();
CorrectTotalRow();
StateHasChanged();
}

public void CorrectTotalRow()
{
((TotalRow?)Rows.Find(r => r is TotalRow))?.Correct();
}
10 replies
CC#
Created by J.BE on 5/9/2023 in #help
❔ Bug in blazor?
The total row shows and calculates the sums of columns 2, 3 and 4. As you can see it works perfectly for the second table but not the first table, and here comes the strangest thing, when i leave out the @if (CategoryLines is not null) check, and thus not show a spinner, it does show the totals for that table! Which is super strange because the second table does not require that! Anyone an idea why this might be?
10 replies
CC#
Created by J.BE on 5/9/2023 in #help
❔ Bug in blazor?
Both tables use the exact same component and child components
<Table Names="@(new[] { "Groep", "Totaal ex.", "Totaal btw", "Totaal incl." })"
MaxRows="@(CategoryLines?.Count ?? 0)">
@if (CategoryLines is not null)
{
@for (var i = 0; i < CategoryLines?.Count; i++)
{
var category = CategoryLines[i];
var index = i;
<Row>
<IntCell Selectable="false" Value="@(index + 1)"/>
<TextCell Value="@category.Name"/>
<DecimalCell Value="@category.TotExcl" Format="C"/>
<DecimalCell Value="@category.Vat" Format="C"/>
<DecimalCell Value="@category.TotIncl" Format="C"/>
</Row>
}
<TotalRow OfColumns="@(new[] { 2, 3, 4 })"/>
}
else { <Spinner/> }
</Table>
<Table Names="@(new[] { "BTW%", "Totaal ex.", "Totaal btw", "Totaal incl." })"
MaxRows="@(VatRateLines?.Count ?? 0)">
@if(VatRateLines is not null) {
@for (var i = 0; i < VatRateLines.Count; i++)
{
var vatRate = VatRateLines[i];
var index = i;
<Row>
<IntCell Selectable="false" Value="@((index + 1))"/>
<DecimalCell Value="@vatRate.Vat" Percentage="true"/>
<DecimalCell Value="@vatRate.TotExcl" Format="C"/>
<DecimalCell Value="@(vatRate.TotIncl-vatRate.TotExcl)"/>
<DecimalCell Value="@vatRate.TotIncl" Format="C"/>
</Row>
}
<TotalRow OfColumns="@(new[] { 2, 3, 4 })"/>
}
else { <Spinner/> }
</Table>
<Table Names="@(new[] { "Groep", "Totaal ex.", "Totaal btw", "Totaal incl." })"
MaxRows="@(CategoryLines?.Count ?? 0)">
@if (CategoryLines is not null)
{
@for (var i = 0; i < CategoryLines?.Count; i++)
{
var category = CategoryLines[i];
var index = i;
<Row>
<IntCell Selectable="false" Value="@(index + 1)"/>
<TextCell Value="@category.Name"/>
<DecimalCell Value="@category.TotExcl" Format="C"/>
<DecimalCell Value="@category.Vat" Format="C"/>
<DecimalCell Value="@category.TotIncl" Format="C"/>
</Row>
}
<TotalRow OfColumns="@(new[] { 2, 3, 4 })"/>
}
else { <Spinner/> }
</Table>
<Table Names="@(new[] { "BTW%", "Totaal ex.", "Totaal btw", "Totaal incl." })"
MaxRows="@(VatRateLines?.Count ?? 0)">
@if(VatRateLines is not null) {
@for (var i = 0; i < VatRateLines.Count; i++)
{
var vatRate = VatRateLines[i];
var index = i;
<Row>
<IntCell Selectable="false" Value="@((index + 1))"/>
<DecimalCell Value="@vatRate.Vat" Percentage="true"/>
<DecimalCell Value="@vatRate.TotExcl" Format="C"/>
<DecimalCell Value="@(vatRate.TotIncl-vatRate.TotExcl)"/>
<DecimalCell Value="@vatRate.TotIncl" Format="C"/>
</Row>
}
<TotalRow OfColumns="@(new[] { 2, 3, 4 })"/>
}
else { <Spinner/> }
</Table>
10 replies