PivotTable
TsgcHTMLComponent_PivotTable — renderizza una tabella pivot Bootstrap che raggruppa righe e colonne e aggrega le misure con totali di riga, colonna e generali, in Delphi, C++ Builder e .NET.
TsgcHTMLComponent_PivotTable — renderizza una tabella pivot Bootstrap che raggruppa righe e colonne e aggrega le misure con totali di riga, colonna e generali, in Delphi, C++ Builder e .NET.
Dichiara i campi di raggruppamento e le misure, alimentala con righe grezze (oppure collega un dataset), quindi leggi la proprietà HTML.
TsgcHTMLComponent_PivotTable
Bootstrap 5 aggregated table + totals
Delphi, C++ Builder, .NET
Aggiungi RowFields / ColumnFields per il raggruppamento, aggiungi una voce Measures per ogni valore aggregato, elenca le colonne di origine in DataFields, inserisci le righe con AddRow, quindi leggi HTML.
uses
sgcHTML_Component_PivotTable;
var
oPivot: TsgcHTMLComponent_PivotTable;
oMeasure: TsgcHTMLPivotMeasure;
begin
oPivot := TsgcHTMLComponent_PivotTable.Create(nil);
try
oPivot.Caption := 'Revenue by Region and Quarter';
oPivot.RowFields.Add.FieldName := 'Region';
oPivot.ColumnFields.Add.FieldName := 'Quarter';
oMeasure := oPivot.Measures.Add;
oMeasure.SourceField := 'Amount';
oMeasure.Caption := 'Revenue';
oMeasure.Aggregation := paSum;
oMeasure.Format := '#,##0.00';
oPivot.DataFields.Add('Region');
oPivot.DataFields.Add('Quarter');
oPivot.DataFields.Add('Amount');
oPivot.AddRow(['EMEA', 'Q1', '12000']);
oPivot.AddRow(['EMEA', 'Q2', '15500']);
oPivot.AddRow(['APAC', 'Q1', '9800']);
WebModule.Response := oPivot.HTML; // aggregated table + row/column/grand totals
finally
oPivot.Free;
end;
end;
// Or bind it straight to a dataset (reads only RowFields/ColumnFields/Measures fields):
oPivot.LoadFromDataSet(qrySales);
// includes: sgcHTML_Component_PivotTable.hpp
TsgcHTMLComponent_PivotTable *oPivot = new TsgcHTMLComponent_PivotTable(NULL);
try
{
oPivot->Caption = "Revenue by Region and Quarter";
oPivot->RowFields->Add()->FieldName = "Region";
oPivot->ColumnFields->Add()->FieldName = "Quarter";
TsgcHTMLPivotMeasure *oMeasure = oPivot->Measures->Add();
oMeasure->SourceField = "Amount";
oMeasure->Caption = "Revenue";
oMeasure->Aggregation = paSum;
oMeasure->Format = "#,##0.00";
oPivot->DataFields->Add("Region");
oPivot->DataFields->Add("Quarter");
oPivot->DataFields->Add("Amount");
oPivot->AddRow(OPENARRAY(UnicodeString, ("EMEA", "Q1", "12000")));
oPivot->AddRow(OPENARRAY(UnicodeString, ("APAC", "Q1", "9800")));
String html = oPivot->HTML; // aggregated table + row/column/grand totals
}
__finally
{
delete oPivot;
}
using esegece.sgcWebSockets;
var pivot = new TsgcHTMLComponent_PivotTable();
pivot.Caption = "Revenue by Region and Quarter";
pivot.RowFields.Add().FieldName = "Region";
pivot.ColumnFields.Add().FieldName = "Quarter";
var measure = pivot.Measures.Add();
measure.SourceField = "Amount";
measure.Caption = "Revenue";
measure.Aggregation = TsgcHTMLPivotAggregation.paSum;
measure.Format = "#,##0.00";
pivot.DataFields.Add("Region");
pivot.DataFields.Add("Quarter");
pivot.DataFields.Add("Amount");
pivot.AddRow(new[] { "EMEA", "Q1", "12000" });
pivot.AddRow(new[] { "APAC", "Q1", "9800" });
string html = pivot.HTML; // aggregated table + row/column/grand totals
I membri che utilizzerai più spesso.
Ogni voce ha un FieldName e un Caption; RowFields raggruppa le righe lungo il lato sinistro, ColumnFields raggruppa le colonne lungo la parte superiore.
Measures.Add restituisce un TsgcHTMLPivotMeasure con SourceField, Caption, un Aggregation (SUM/COUNT/AVERAGE/MIN/MAX) e una maschera Format opzionale.
DataFields elenca posizionalmente le colonne di origine grezze; AddRow(aValues) aggiunge una riga che rispetta quell’ordine.
LoadFromDataSet(aDataSet) legge direttamente da un TDataSet solo i campi referenziati da RowFields, ColumnFields e Measures.
ShowRowTotals, ShowColumnTotals e ShowGrandTotal attivano ciascuno una riga/colonna di riepilogo; TotalText ne definisce l’etichetta.
Striped, Bordered, Hover e Compact definiscono lo stile della tabella Bootstrap; EmptyCellText riempie le celle vuote; HTML restituisce la tabella finita.
| Guida in lineaRiferimento API completo e guida all’uso per questo componente. | Apri | |
| Tutti i componenti sgcHTMLEsplora la matrice completa delle funzionalità di oltre 80 componenti. | Apri | |
| Scarica la Prova GratuitaLa prova di 30 giorni include i progetti demo 60.HTML. | Apri | |
| PrezziLicenze Single, Team e Site con codice sorgente completo. | Apri |