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

[Datagrid]: Support specifying initial states for newly added rows in Datagrid #5260

Closed
2 tasks done
flannanl opened this issue May 17, 2024 · 2 comments · Fixed by #5261
Closed
2 tasks done

[Datagrid]: Support specifying initial states for newly added rows in Datagrid #5260

flannanl opened this issue May 17, 2024 · 2 comments · Fixed by #5261
Assignees

Comments

@flannanl
Copy link

Package

Carbon for IBM Products

Description

Based on https://carbon-for-ibm-products.netlify.app/?path=/docs/ibm-products-components-datagrid-nestedrows--docs#with-initially-expanded-nested-rows, there is currently a way to specify the initial expansion state for nested rows. However, this requires the data or rows to be ALL available before very first time rendering the Datagrid.

In our use case, this is impossible because we fetch data at a later time in paginations. So as we render the Datagrid, we want it to be in loading state and then as data comes in, we will start adding rows to the Datagrid. Because of this, we will never have enough data / info to populate the initial state we want.

Secondly, the initial state currently seems to be based on the actual row IDs, which is generated by Datagrid. There is no way for us to know the actual row ID ahead of time before we render the Datagrid table.

We would like to have a few enhancements and behaviour change:

  1. One of our other use cases is that after doing certain actions from Datagrid table, we will create a new nested row, which we want it to be expanded by default. Today, we have no such way to do so. Therefore we would like to have a way to specify an initialState for this new row to tell Datagrid to expand or select it at re-render time. After rendering with the new row(s), the initialState should be thrown away and let the users to manage the states afterward.
  2. We would like the initialState to use the id in the data array instead. This is the ID we know ahead. So Datagrid should use the data.id whenever possible and then fallback to the actual row id if it is missing.
  3. We want a way to specify the initialState of multiple rows as they being injected to the table. This is similar to (1), so if (1) is solved, I believe this will be solved as well.
  4. Today, the initialState only deals with expansion state, it will be good if it can also deal with selection state.

Component(s) impacted

IBM Projects UI: https://cloud.ibm.com/projects

Browser

Chrome, Safari, Firefox, Microsoft Edge

@carbon/ibm-products (previously @carbon/ibm-cloud-cognitive) version

1.72.2

Severity

Severity 2 = Aspects of design is broken, and impedes users in a significant way, but there is a way to complete their tasks. Affects major functionality, has a workaround.

Product/offering

IBM Cloud Projects

CodeSandbox or Stackblitz example

N/A

Steps to reproduce the issue (if applicable)

No response

Release date (if applicable)

No response

Code of Conduct

@matthewgallo
Copy link
Member

@flannanl ok if we open a separate issue for number 2 in the list you provided above?

@flannanl
Copy link
Author

Sure, go ahead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done 🚀
Development

Successfully merging a pull request may close this issue.

2 participants