Search code examples
htmlgrailsgsp

Adding text from property after each row in table gsp


I want to add some text from an object property after each row of a table that contains a list of objects!

each row presents some properties and i need to add text that is passed from a property as well ( in div or some other container) under each row .

is there anyway to do this ?! all tips appreciated !

Here is sample of my code !

    <table>
        <thead>
        <tr>
        <g:sortableColumn />
        <g:sortableColumn />
        <g:sortableColumn />
        <g:sortableColumn />
        </tr>
        </thead>
        <tbody>
        <g:each in="${fpsList}" var="ft">
            <tr>
                <td> ${ft.sth}</td>
                <td> ${ft.sth1}</td>
                <td> ${ft.sth2}</td>

           /*i need to do some thing like this
 <div> Note:${ft.information </div> */

        </tr>

        </g:each>
        </tbody>
    </table>

Solution

  • In order to add another row below the existing row for each domain class in your list you simply need to add another <tr> after the existing one.

    For example:

    <table>
        <thead>
        <tr>
        <g:sortableColumn />
        <g:sortableColumn />
        <g:sortableColumn />
        <g:sortableColumn />
        </tr>
        </thead>
        <tbody>
        <g:each in="${fpsList}" var="ft">
            <tr>
                <td>${ft.sth}</td>
                <td>${ft.sth1}</td>
                <td>${ft.sth2}</td>
            </tr>
            <tr>
                <td colspan="3">
                    <div>Note:${ft.information}</div>
                </td>
            </tr>
        </g:each>
        </tbody>
    </table>
    

    What the above does is add another row, with a single column that spans the width of the three columns in the table. Placing the data div and domain property within it.

    There are plenty of good HTML guides out there. W3Schools is a nice place to start learning.