Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable: options object passed to paginator templates does not match typescript interface #7225

Open
NothingFiner opened this issue Sep 19, 2024 · 3 comments
Labels
Typescript Issue or pull request is *only* related to TypeScript definition

Comments

@NothingFiner
Copy link

NothingFiner commented Sep 19, 2024

Describe the bug

it's quite easy to work around this issue by using any or writing one's own interface. However, I noticed that the options object passed to paginator templates from a data table does not match the interface provided.
options object:
Screen Shot 2024-09-19 at 11 03 12 AM
interface provided:
Screen Shot 2024-09-19 at 11 04 50 AM

Specifically, a lot of the keys that are supposed to be at root level are nested inside of props object. My best guess is that this is an oversight, but I don't know to what else it might relate. It could be that there's some sort of bifurcation between the pagination component and its use here. I would be happy to work up a PR for this if there is not an issue.

This is also the case with other template options--ie the other elements of the paginator.

Reproducer

No response

System Information

"primereact": "^10.6.5",
"react": "18.2.0",

Steps to reproduce the behavior

  1. in an app with primereact render a datatable component with something like the following attributes
    ref={dt} loading={isFetching} value={data?.products || []} dataKey='id' paginator={data?.products?.length > 12} rows={12} onSort={sortHandler} sortField={dataTableSort.sortField} sortOrder={dataTableSort.tableSortOrder as 1 | 0 | -1} rowsPerPageOptions={[12, 24, 36]} paginatorTemplate={{ LastPageLink: LastPageLinkTemplate, layout: 'RowsPerPageDropdown PrevPageLink FirstPageLink PageLinks LastPageLink NextPageLink', }} pageLinkSize={3} emptyMessage='No products found.' sortIcon={SortIconTemplate}

and a template something like this

`const LastPageLinkTemplate = (options: any) => {
debugger;

return (

... {options.props.totalPages}

);
};
`

  1. observe discrepency between options object passed and the PaginatorLastPageLinkOption interface.

Expected behavior

the options object passed to the template should match the provided interface

@NothingFiner NothingFiner added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 19, 2024
@melloware melloware added Typescript Issue or pull request is *only* related to TypeScript definition and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Sep 19, 2024
@melloware
Copy link
Member

@NothingFiner interested in submitting a PR?

@NothingFiner
Copy link
Author

@melloware I would be, but I would also like to know if there's a preference for if it would be better to update the interface, add a new interface, or look into why it might be different more.

If it's the last option, I will need some time! I could also update the docs to show how to use template in this manner.

I'm not sure if this kind of functionality is supposed to be deprecated or what, but this is not accurate.
Screen Shot 2024-09-19 at 11 30 00 AM
in reality it takes a string or an options object

@melloware
Copy link
Member

If you update the .d.ts files it automatically updates the website docs you pointed to. So if you modify to PaginatorTemple | string it will just show up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
Development

No branches or pull requests

2 participants