Make a default row selection in prime react datatable

UI Components for React
Post Reply
Abhilashk
Posts: 1
Joined: 04 Aug 2022, 17:10

04 Aug 2022, 17:19

Hello All,

I am using the prime react datatable with reactJS,
The selection is set to 'Single' and we have a master detail structure on page.
On load or search, Is there way we can set first row as default selected row on master table, so the child is populated according to the first row in master.

Thanks in advance,
Abhilash

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

05 Aug 2022, 14:30

Yes instead of defaulting your selection to NULL.

Code: Select all

const [selectedProduct1, setSelectedProduct1] = useState(null);
Default it to the row you want selected.

Code: Select all

const [selectedProduct1, setSelectedProduct1] = useState(mySelectedProduct);
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Santhosh Veluru
Posts: 2
Joined: 08 Aug 2023, 06:03

08 Aug 2023, 06:23

It is selecting the first row on page load,
But the key support is not working.
It is not focusing on the other rows until and unless we click on any row int the DataTable.
How to achieve that functionality.

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: AustinduG and 10 guests