Skip to content

Reports

zehavibarak edited this page Oct 27, 2022 · 1 revision

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.

Angular

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.

ReportRef

The ReportRef enables the report to access executing context, such as report progress event and resize.

Arguments

You can also customize the arguments pane by implementing IArgumentComponent<T> and annotating the arguments model with the Template attribute.

Options

Set the Options node in bizdoc.json to pass values to the report backend properties.

Built-in reports

usage, documents and tasks

Release Notes

Angular npm, Flutter pub.dev and Nuget packages.

Clone this wiki locally