• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic generation of row column and header

 
Niza Berg
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to code a table in which row and column, and headers are dynamic. Previously I was hard coding the table in HTML and headers display tag for displaying details from Database. Now since column, and headers are also varying as per different requirement in my project I needed to do everything dynamic. Any suggestions on what to use would be appreciated.

So this is how I was doing it earlier:


From the above `<table>` schema, the header is hard coded. Now I needed to make it dynamic and based on any particular requirement and selection my servlet will query and pass results in such dynamically behavior table.

Any help on this would be really really helpful and great!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65664
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recommendation #1: Use lowercase for your HTML markup. Using all uppercase went out of vogue at the turn of the millennium.

Recommendation #2: Add another list to the scope that contains the list of column headers and iterate over it to create the headers in the same way you are now creating the data rows.

Recommendation #3: Restructure your data list to a simple nested List rather than having to create complex calls. Yes, you can do lists within lists and you can nest two forEach actions to iterate through each row, and then each data cell.

Recommendation #4: Use better names. values, for example, is so generic as to be useless as a descriptor.

Recommendation #5: Use CSS properly for the table. border, cellspacing and cellpadding should not be used. Avoid style elements in the markup. Apply styles with stylesheets.
 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!