Search code examples
twitter-bootstrapgrailsgsp

Insert icon with g:sortableColumn in grails


how to insert an icon in grails g:sortableColumn tag

<g:sortableColumn property="name" title="${message(code:'project.name.label', default: 'Name')}" /> 
<g:sortableColumn property="age" title="${message(code:'project.age.label', default: 'Age')}" />    
<g:sortableColumn property="phoneNumber" title="${message(code:'project.phoneNumber.label', default: 'Phone Number')}" />

i want to insert any one icon along with these table header like this using bootstrap glyphicon or Font Awesome icon

enter image description here


Solution

  • This works with Grails 3.

    Place image in /grails-app/assets/images for this example were using a file named sort_both.png Then in your gsp...

    <style type="text/css">
            .headerSort{
                background-repeat: no-repeat;
                background-position: right;
                background-image: url("${assetPath(src: 'sort_both.png')}")
            }
    </style>
    
    ...
    
    <g:sortableColumn class="headerSort" property="name" title="${message(code:'project.name.label', default: 'Name')}" /> 
    ...