Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

comparator.constructors[0].newInstance([domainClass] in grails 3

<table class="table table-striped">
    <thead>
        <tr>
        <%
            def grailsApplication = grails.util.Holders.grailsApplication
            domainObjetc = grailsApplication.domainClasses.find { it.clazz.simpleName == className }.clazz.newInstance()
            domainClass=  grailsApplication.getDomainClass(domainObjetc.class.name)
            excludedProps = grails.persistence.Event.allEvents.toList() << 'id' << 'version'
            allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'
            props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && it.type != null && !Collection.isAssignableFrom(it.type) }
            comparator = new org.grails.validation.DomainClassPropertyComparator(domainClass)
            Collections.sort(props, comparator)
            props.eachWithIndex { p, i ->
                if (i < 6) {
                    if (p.isAssociation()) { 
                        %><th class="header"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></th><%
                    } else { 
                        %><g:sortableColumn property="${p.name}" title="${message(code: '${domainClass.propertyName}.${p.name}.label', default: '${p.naturalName}')}" /><%
                    }   
                }   
            }%>
            <th></th>
        </tr>
    </thead>
    <tbody>
    <g:each in="${${propertyName}List}" var="${propertyName}">
        <tr>
        <%  props.eachWithIndex { p, i ->
                if (i < 6) {
                    if (p.type == Boolean || p.type == boolean) { %>
            <td><g:formatBoolean boolean="${${propertyName}.${p.name}}" /></td>
        <%          } else if (p.type == Date || p.type == java.sql.Date || p.type == java.sql.Time || p.type == Calendar) { %>
            <td><g:formatDate date="${${propertyName}.${p.name}}" /></td>
        <%          } else { %>
            <td>${fieldValue(bean: ${propertyName}, field: "${p.name}")}</td>
        <%  }   }   } %>
            <td class="link">
                <div class="btn-group btn-group-xs">
                    <g:link action="show" id="${${propertyName}.id}" class="btn btn-primary btn-sm" role="button">
                        <span class="glyphicon glyphicon-eye-open"></span>
                        <g:message code="default.button.show.label" default="Show" />
                      </g:link>
                      <g:link action="edit" id="${${propertyName}.id}" class="btn btn-primary btn-sm" role="button">
                        <span class="glyphicon glyphicon-pencil"></span>
                        <g:message code="default.button.edit.label" default="Edit" />
                      </g:link>
                </div>
            </td>
        </tr>
    </g:each>   
    </tbody>
</table>
Comment

PREVIOUS NEXT
Code Example
Ruby :: rollback specific migration rails 
R :: convert latin accents to ascii R 
R :: how to create dates in a range in R 
R :: r - remove scientific notations 
R :: how to set a column as index r 
R :: remove elements from character vector in r 
R :: find data type of vector r 
R :: collapse text by group in dataframe r 
R :: r na omit column 
R :: rnorm r 
R :: r rename columns 
R :: r bar plot 
R :: grid.arrange 
R :: how to combine all columns into one column in r 
R :: filter date in r 
R :: create a table from dataframe in r 
R :: r convert to factor 
R :: how to throw an error in R 
R :: Reorder bars in geom_bar ggplot2 by value 
R :: convert int to character R 
R :: how to remove columns in a table in r 
R :: convert a column to row names in r 
R :: no redundant combination expand grid 
R :: r create intervals cut 
R :: dotted y intercept line in ggplot 
R :: change the font of the title in a plot in r 
Rust :: rust lang sleep 
Rust :: rust get items in a list with index and value 
Rust :: rust into string 
Rust :: optional arguments rust 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =