Datatable insertion order

UI Components for JSF
Post Reply
jackstuard
Posts: 28
Joined: 03 Aug 2011, 15:53

29 Jun 2017, 14:30

Hello,

I have a case where I need to insert a items to the beginning of a datatable (imagine a case where the user choose a role from a autocomplete and add it to List, that will appear in a datatable).
My doubt is, how can I make the last item added appear on top of the datatable?
I see some scenarios but I'm curious to know if there is a better approach:

1. Use list.add(0, myObject);
or
2. Create a wrapper object that has a field called insertedDateTime then use the sortBy param from dataTable.

Any suggestion?

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

29 Jun 2017, 15:35

1: works 'now'
2: will keep working in the future to if you don't add a wrapper but add it to the model.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 72 guests