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

Feature Request: DataTable hide expander when there are no children rows #1762

Closed
bmstambaugh opened this issue Jan 19, 2021 · 6 comments
Closed
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@bmstambaugh
Copy link

bmstambaugh commented Jan 19, 2021

I'm submitting a ...

[ ] bug report
[X] feature request
[ ] support request

Expected behavior
I would like to ability to hide the expander of a row that has no children

@mertsincan mertsincan self-assigned this Jan 28, 2021
@mertsincan mertsincan added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Jan 28, 2021
@mertsincan mertsincan added this to the 6.0.1 milestone Jan 28, 2021
@mertsincan
Copy link
Member

mertsincan commented Jan 28, 2021

Hi,

Added body property support to Column with expander. Exp;

<Column expander style={{ width: '3em' }} body={(rowData, columnProps) => {
        return rowData.name.indexOf('a') > -1 ? columnProps.expander.element : null;
 }} />
<Column field="name" header="Name" sortable />

// other columns

With this feature, you can provide custom expander items using columnProps.expander

columnProps.expander -> {onClick: function, className: string, iconClassName: string, element: Element};

Best Regards,

@pieandcakes
Copy link
Contributor

@mertsincan I tried your sample above and every time I use `columnProps.expander.element' typeScript complains:
image

Can you tell me what I'm doing wrong?

@Kaizer69
Copy link

The problem is with colums.td.d that has wrong type definition for ColumnProps.expander: boolean.

Workaround:

const expander = columnProps.expander as unknown as any;
return showExpander ? expander.element : null;

@melloware
Copy link
Member

@Kaizer69 why not submit a PR with your fix?

@Kaizer69
Copy link

I'm not sure about fix it in the correct way of primereact developers (choice the correct type), so it can be a useless PR :)

@mertsincan
Copy link
Member

Hi,
Fixed in #2328

Best Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

5 participants