I am using the Display tag Java library in my web application. I need to group some column headers ("General" and "Office Info") as shown in the following example.
-
@Remy It is a third party library used in java web aplications for listing and pagination purposes. Please refer http://www.displaytag.org/1.2/ – ajm May 14 '12 at 11:51
-
No answers as yet? Is it possible to do it at all or shall I just forget about doing it? – ajm May 16 '12 at 12:58
-
1check this http://stackoverflow.com/questions/1831631/can-we-use-rowspan-and-colspan-in-displaytag – Dhiraj May 17 '12 at 10:55
-
3get the sourcecode of displaytag and edit it. i havent done the exact same thing you are trying to achieve but I have done subtotalling and totallings of the numeric column data and like into a separate cell on the last row. For that I extended the table and added one or two methods of my own. – skipy May 18 '12 at 14:56
-
look at this example: http://www.java2s.com/Code/Java/Swing-Components/GroupableGroupHeaderExample.htm – John Woo May 21 '12 at 08:24
-
@johntotetwoo The question is about using the DisplayTag 3rd party plug-in for Web applications. your Swing answer is not relevant. – Brad Jun 07 '12 at 16:11
-
How this can be implemented in Core Java, Swing programming.. I too have same situation to work on with an requirement.. – Gnanam R Aug 20 '12 at 10:03
2 Answers
Ashish, I tried to clarify your question and have hopefully got it right.
If you check the HTML source generated by DisplayTag it puts the column headings into a <thead>
tag like this
<table cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="dtsortable">
<a href="...">Firstname</a>
</th>
<th class="dtsortable">
<a href="...">Lastname</a>
</th>
</tr>
</thead>
<tbody>
...
So what you want to achieve is inserting a new row into the for your groupings. I would suggest that the easiest way to achieve this is not to mess with DisplayTag code and use JQuery to manipulate the DOM to do this.
Using JQuery
To get this HTML code...
<table id="display-tag "cellspacing="0" cellpadding="0">
<thead>
<tr>
<th colspan="2">
heading
</th>
</tr>
<tr>
<th class="dtsortable">
<a href="...">Firstname</a>
</th>
<th class="dtsortable">
<a href="...">Lastname</a>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bob</td>
<td>Test</td>
</tr>
<tr>
<td>Jane</td>
<td>Test</td>
</tr>
</tbody>
</table>
You can use this JQuery code...
$('#display-tag > thead').prepend('<tr><th colspan="2">heading</th></tr>');

- 15,186
- 11
- 60
- 74
you will do like this
Roles CASBAdmin TEUser PubUser PWUser MedUser CommonUser " sortable="true">

- 1