-
Notifications
You must be signed in to change notification settings - Fork 2
Reports
A report component consists of a data model, a backing class, and an arguments class.
public class MyReportDataModel
{
[Key]
public int Id { get; set; }
public string Product { get; set; }
public decimal? Price { get; set; }
}
public struct MyReportArgsModel
{
public DateTime Starting { get; set; }
}
[Report(title: "My report")]
public class MyReport : ReportBase<MyReportArgsModel, MyReportDataModel>
{
private readonly CustomStore _store;
public MyReport(CustomStore store) {
_store = store;
}
public override async Task<IEnumerable<MyReportDataModel>>
PopulateAsync(MyReportArgsModel args, IProgress<int> progress) =>
await _store.Lines.Select(l=> new MyReportDataModel {
Product = l.Product,
Price = l.Price,
...
}).ToListAsync();
}The above PopulateAsync method accepts MyReportArgsModel and returns a list of MyReportDataModel retrieved from database.
Annotate model properties with Display and DataType attributes to control their layout.
To create a custom web app report, add an Angular component and implement IReportComponent<T>.
import {ReportComponent, BizDoc, ReportRef} from '@bizdoc/core';
@Component({...})
@BizDoc({ selector: 'my-report' })
export class MyReport implements ReportComponent<MyReportModel, MyReportArgs> {
constructor(@Inject(ReportRef) private _ref: ReportRef) { }
onBind(data: MyReportModel[]) {
...
}
}
interface MyReportModel { ... }
interface MyReportArgs { ... }The MyReportModel and MyReportArgs above maps to the server-side models.
If no Angular component is registered for the report, BizDoc treats the model properties as columns and the arguments as filters.
The ReportRef enables the report to access executing context, such as report progress event and resize.
You can also customize the arguments pane by implementing IArgumentComponent<T> and annotating the arguments model with the Template attribute.
Set the Options node in bizdoc.json to pass values to the report backend properties.
Moding Ltd.