How to group column headers using the Display tag Java library?
Asked Answered
R

2

13

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.

enter image description here

Repentant answered 12/5, 2012 at 10:12 Comment(7)
@Remy It is a third party library used in java web aplications for listing and pagination purposes. Please refer displaytag.org/1.2Repentant
No answers as yet? Is it possible to do it at all or shall I just forget about doing it?Repentant
check this #1832131Titration
get 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.Subterfuge
look at this example: java2s.com/Code/Java/Swing-Components/…Hartsfield
@johntotetwoo The question is about using the DisplayTag 3rd party plug-in for Web applications. your Swing answer is not relevant.Alluvium
How this can be implemented in Core Java, Swing programming.. I too have same situation to work on with an requirement..Meeting
A
3

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>');

You can see this in action with this JSFiddle

Alluvium answered 7/6, 2012 at 17:9 Comment(0)
P
-3

you will do like this

Roles CASBAdmin TEUser PubUser PWUser MedUser CommonUser " sortable="true">

Propound answered 23/1, 2014 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.