I want to use DetailsList component https://developer.microsoft.com/en-us/fluentui#/controls/web/detailslist and select items. As I understand, the component doesn't provide us a prop to get selected items. I only see onActiveItemChanged
prop which is only giving me single item but not all selected items.
Getting selected items in Fluent UI DetailsList
Because of this reason -maybe I can also have other problem in the future-, I couldn't use state, as well.
I will be very glad if I can get current selected checkboxes on DetailsList component.
I found the answer.
import Selection
from @fluentui/react
Add selection={selection}
to DetailsList props
and then do this before returning the component:
const selection = new Selection({ onSelectionChanged: () => { const selectedItems = selection.getSelection(); // Do something with the selected items' console.log(selectedItems, 'ewgergre'); }, });
I didn't understand why it doesn't format my code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.