Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filtering in the primefaces datatable having large dataset

 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table with more than 4000 records for which i need to implement datatable.I also need to provide filtering for this datatable similar to the one shown in showcase and it needs to be applied to all the records. Datatable shouldn't have pagination.Which is the best way to implement this,do i need to go with live scrolling or lazy loading.The main thing is i need to do filtering on all the records.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If at any time you display anything near 4000 records on a single webpage you will not only experience serious performance issues (it can take a LONG time to assemble and ship that large a page), you may blow out the client's browser, and the users will end up with bleeding eyeballs to boot.

Unless you can absolutely guarantee that no more than about 100 records will be displayed at any time, you should seriously reconsider using some sort of pagination. And if you have idiot management that forbids it, you should use the time otherwise spent coding to update your CV, because if they're that incompetent, things can only get worse and you are well-advised to seek employment in a shop where sanity is more common.

You can assemble a datatable which acts as a window on a large array by constructing a UI model object. For example, an array or List which contains only the details of interest. You can do this in Java because an array or List doesn't "own" its contents, it merely references them. So two different arrays or Lists (or mix of the 2) can both reference the same detail row object.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakshith Sridharamurthy wrote:Datatable shouldn't have pagination

Is that an actual requirement? Even if each row contains a small amount of data (so an impact on performance was negligible), are the users prepared to scroll down the page forever?

Also, instead of filtering on the entire 4000 records, would it not be wiser to implement a search facility? Imagine a user coming along and having to wait for all 4000 records to load before filtering to find a single record. Doesn't sound very user-friendly to me.
 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for giving your thoughts on this.The requirement of the client is the entire table containing about 4000 records must be searched on a specific column.I want to ask if we can get this kind of functionality using pagination or live scrolling or any other way.This functionality is very important.Please give suggestion how i can do this.
Thanks in advance.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can. Although it's possible even with basic core JSF to get this kind of behavior by brute force, many of the extension tag sets such as RichFaces have extensive capabilities in this regard.

As far as I know, Primefaces does also.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakshith Sridharamurthy wrote:
I also need to provide filtering for this datatable similar to the one shown in showcase and it needs to be applied to all the records

I assume you are talking about this:
Datatable Filtering

This looks like it will meet you requirements, what functionality does it not provide for you?
 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is even if i am present at initial records i should be able to search the records present in ending rows based on a search criteria.Is that possible using primefaces?Using Datatable filtering(with pagination or live scrolling)
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that the filtering works solely on the content of the datatable. As long as you place the results of your search in the datatable, the filtering controls will do the rest.
 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim and James for providing valuable suggestion.I will try to implement this using primefaces datatable filtering.
One last question the primefaces datatable which i am going to have is a cell editable with multiple selection,is datatable filtering with lazy loading possible with this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic