enterprise-ng
enterprise-ng copied to clipboard
Datagrid: Add missing typings and interface
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:
- Add
(cellChange)="onCellChange($event)"event on your datagrid. - Log the event object and you will find
apiandrowData(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
}
}
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, 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:
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.
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.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Hi @tmcconechy
We are still facing issues with SohoDataGridCellChangeEvent and rowData property that "Doesn't exist on type SohoDataGridCellChangeEvent"