microsoft / fluentui

Fluent UI web represents a collection of utilities, React components, and web components for building web applications.
https://react.fluentui.dev
Other
18.57k stars 2.74k forks source link

[Feature]: Is there a way to add a footer row or a filter row in datagrid #32257

Open it950 opened 3 months ago

it950 commented 3 months ago

Library

React Components / v9 (@fluentui/react-components)

Describe the feature that you would like added

1, How to add a footer to DataGrid, the footer show the sum field and sticky to the bottom of DataGrid, like DetailList v8 onRenderDetailsFooter property;

2, How to add a sticky filter row under the DataGridHeader;

3, In DetailList v8, there are some properties listed below, and how to implement in v9 DataGrid equivalently.

onActiveItemChanged, which is a callback for when an item in the list becomes active by clicking anywhere inside the row or navigating to it with the keyboard.

onItemInvoked, which is a  callback for when a given row has been invoked (by pressing enter while it is selected.)
onColumnResize, which is a callback fired on column resize

Have you discussed this feature with our team

No response

Additional context

No response

Validations

Priority

None

miroslavstastny commented 3 months ago

This is currently not possible, tracking as a feature request

DigitalFlow commented 2 months ago

I would not say it's not possible.

I achieved this by adding a column with a specific ID and a custom sort function that puts this column always last / first depending on the sort direction.

Values have to be calculated by code then when rendering. We even managed to implement collapsible rows with children like this.

it950 commented 2 months ago

The footer is very user-friendly and the user can view the summary of the dataGrid row directly, in v8, this is very easy, the following pictue is DetailList footer in fluentui v8: image

DigitalFlow commented 2 months ago

Yes you're right, but this is super easy to implement in datagrid as well.

You can just add an extra item to your "items" collection with a marker like an empty guid as rowId and in your createTableColumn functions you can check for this is and if you find it, don't render the columns value but instead access the whole items collection and aggregate it. And when sorting you can take care of putting it always last.

It's really not much effort.