Make a default row selection in prime react datatable

UI Components for React
Post Reply
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,

Posts: 3245
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:
PrimeFaces Elite 11.0.3 / PF Extensions 11.0.3
PrimeReact 8.0.0

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest