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

Option to enable/disable adding rows #1592

Closed
gomorizsolt opened this issue Jan 30, 2020 · 7 comments
Closed

Option to enable/disable adding rows #1592

gomorizsolt opened this issue Jan 30, 2020 · 7 comments
Assignees
Labels
question Further information is requested waiting for contributor

Comments

@gomorizsolt
Copy link

gomorizsolt commented Jan 30, 2020

Is your feature request related to a problem? Please describe.

We'd like to disable adding rows if the client reaches a certain limit of items.

Describe the solution you'd like

Looking for an option to control the "add" button's disabled property just as e.g. isEditable disables editing rows.

Describe alternatives you've considered

Our alternative solution goes as follows.

  1. Set editable.onRowData to undefined(Disable add button when Editable if the field in last row has x value #465).
editable={{
   onRowAdd: (...) => this.maxLimitReached() ? undefined : this.add(...)
}}
  1. Display a "placeholder" in place of the "hidden" onRowAdd icon.
actions={[
   {
      icon: "add_box",
      tooltip: "...",
      isFreeAction: true,
      disabled: true,
      hidden: !this.maxLimitReached()
      onClick: () => {}
   }
]}
@thisismydesign
Copy link

Btw I don't understand the solution in #465. AFAICT the request was also to be able to "disable the add button", but the issue was closed without solving this. You could also reopen that one as it already had some engagement.

Our workaround works but is very hacky.

@stale
Copy link

stale bot commented Jun 30, 2020

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 contributions. You can reopen it if it required.

@stale stale bot added the wontfix This will not be worked on label Jun 30, 2020
@thisismydesign
Copy link

Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

@stale stale bot removed the wontfix This will not be worked on label Jul 1, 2020
@Domino987 Domino987 self-assigned this Jul 14, 2020
@Domino987 Domino987 added question Further information is requested waiting for contributor labels Jul 14, 2020
@Domino987
Copy link
Collaborator

So how about:
editable={{ onRowAdd: this.maxLimitReached() ? (...) => this.add(...) : undefined }}

@thisismydesign
Copy link

I believe that was the quite uncomfortable workaround we used where we had to hide and replace the button instead of simply controlling its disabled property.

@Domino987
Copy link
Collaborator

Fixed with isEditable prop of editable

@thisismydesign
Copy link

Hey @Domino987, I tried isEditable on 1.62.0 and it doesn't address this issue.

The following still lets me add new rows.

editable={{
  isEditable: () => false
})

We'd like a way to disable adding new rows in a user-friendly manner, such as a disabled Add button (perhaps with a tooltip). There seemed to be interest from others as well. Could you re-open this issue?

The following simply makes the Add button disappear:

editable={{
   onRowAdd: undefined
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested waiting for contributor
Projects
None yet
Development

No branches or pull requests

3 participants