enterprise-ng icon indicating copy to clipboard operation
enterprise-ng copied to clipboard

Datagrid: Add missing typings and interface

Open whernebrink opened this issue 3 years ago • 5 comments

Describe the bug Would be good to add missing typings for SohoDataGridCellChangeEvent:

  • api
  • rowData

I think there needs to be a new interface created for the api prop since that has e.g. getActiveDataset() which is a method you can't find in the enterprise-ng project.

To Reproduce Steps to reproduce the behavior:

  1. Add (cellChange)="onCellChange($event)" event on your datagrid.
  2. Log the event object and you will find api and rowData (perhaps others too which is not on the SohoDataGridCellChangeEvent interface).

Expected behavior Not get errors when accessing api or rowData on the event object.

Version

  • ids-enterprise-ng: 10.11.0

Additional context Would be great if the interface for rowData cold get a generic since everyone will have different rows, but it would be great with type safety on these:

// ids code
interface SohoGridCellChangeEvent<T = Object> {
  rowData: T;
}


// consumer code
interface MyRowData {
  locale: string;
  value: string;
}

class FakeComponent {
  onCellChange(event: SohoGridCellChangeEvent<MyRowData>) {
    const { locale, value } = event.rowData; // <-- now we get type safety here
  }
}

whernebrink avatar Dec 19 '21 22:12 whernebrink

Hi @whernebrink I'm not 100% sure i am wrapping my head around this change? Is it literally just

interface SohoGridCellChangeEvent<T = Object> {
  rowData: T;
}

Would welcome a PR on this one if you can?

tmcconechy avatar Dec 20 '21 14:12 tmcconechy

@tmcconechy, well yes and no. Yes, since rowData is missing, I think adding it to the SohoGridCellChangeEvent with the generic would be sufficient. The other part is adding the api property which is also missing, but really usefull.

However, it has a lot of stuff to it. I'm mainly interested in the datagrid prototype methods e.g. getActiveDataset() and the ones for setting/clearing errors on rows and columns. Here is a sceenshot of the logged event in the console:

image image image etc...

So, when adding the api: SomeInterfaceThatExtendsSomeSohoStatic? to the SohoGridCellChangeEvent i'm not sure what should be on that interface, and what to extend (since i'm not sure where all those props and methods come from).

With some help, determining what the api prop's interface should extend or be, I could help out with the PR.

whernebrink avatar Dec 20 '21 19:12 whernebrink

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.

github-actions[bot] avatar May 06 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 20 '24 01:05 github-actions[bot]

Hi @tmcconechy We are still facing issues with SohoDataGridCellChangeEvent and rowData property that "Doesn't exist on type SohoDataGridCellChangeEvent"

IdaAspen avatar May 22 '24 10:05 IdaAspen