goetzrobin / spartan

Cutting-edge tools powering Angular full-stack development.
https://spartan.ng
MIT License
1.22k stars 133 forks source link

Data table: record of objects instead of record of booleans for BrnColumnManager #137

Closed juancarlosgzs closed 6 months ago

juancarlosgzs commented 7 months ago

Which scope/s are relevant/related to the feature request?

data-table

Information

Find a way to add extra parameters to the BrnColumnManager, making it possible to use other values when needed.

Use case: Being able to access a column title when iterating through _brnColumnManager.allColumns

Describe any alternatives/workarounds you're currently using

The current workaround is to use a mapping object <[key: ColumnName]: title>, that is accessed from the HTML with the corresponding columnName that is received from the iteration of _brnColumnManager.allColumns. This causes a [probably] unnecessary duplicated code:

  protected readonly _brnColumnManager = useBrnColumnManager({
    status: true,
    reference: true,
    paymentType: true,
    serviceMethod: true,
    city: true,
    createdBy: true,
    createdAt: true,
    actions: true,
  });

 protected readonly _columnTitles = {
    status: 'Status',
    reference: 'Reference',
    paymentType: 'Payment Type',
    serviceMethod: 'Service Method',
    city: 'City',
    createdBy: 'Created by',
    createdAt: 'Date',
    actions: 'Actions',
  };

I would be willing to submit a PR to fix this issue

goetzrobin commented 6 months ago

@juancarlosgzs this will be supported in the next alpha. You'll be able to do something like this:

  protected readonly _brnColumnManager = useBrnColumnManager({
    status: { visible: true, label: 'Status' },
    ...
  });

All that is required will be that the object passed conforms to {visible: boolean}, which means you could add whatever metadata necessary!

goetzrobin commented 6 months ago

This should work in the new alpha