- Timestamp:
- Feb 28, 2010, 5:25:46 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/taglib/CustomTagLib.groovy
r343 r417 125 125 } // checkBoxList 126 126 127 def sortableColumnWithImg = { attrs, body -> 128 def writer = out 129 if(!attrs.property) 130 throwTagError("Tag [sortableColumn] is missing required attribute [property]") 131 132 // if(!attrs.title && !attrs.titleKey) 133 // throwTagError("Tag [sortableColumn] is missing required attribute [title] or [titleKey]") 134 135 def property = attrs.remove("property") 136 def action = attrs.action ? attrs.remove("action") : (actionName ?: "list") 137 138 def defaultOrder = attrs.remove("defaultOrder") 139 if(defaultOrder != "desc") defaultOrder = "asc" 140 141 // current sorting property and order 142 def sort = params.sort 143 def order = params.order 144 145 // add sorting property and params to link params 146 def linkParams = [:] 147 if(params.id) linkParams.put("id",params.id) 148 if(attrs.params) linkParams.putAll(attrs.remove("params")) 149 linkParams.sort = property 150 151 // determine and add sorting order for this column to link params 152 attrs.class = (attrs.class ? "${attrs.class} sortable" : "sortable") 153 if(property == sort) { 154 attrs.class = attrs.class + " sorted " + order 155 if(order == "asc") 156 linkParams.order = "desc" 157 else 158 linkParams.order = "asc" 159 } 160 else 161 linkParams.order = defaultOrder 162 163 // determine column title 164 // def title = attrs.remove("title") 165 // def titleKey = attrs.remove("titleKey") 166 // if(titleKey) { 167 // if(!title) title = titleKey 168 // def messageSource = grailsAttributes.getApplicationContext().getBean("messageSource") 169 // def locale = RCU.getLocale(request) 170 // 171 // title = messageSource.getMessage(titleKey, null, title, locale) 172 // } 173 174 // Image. 175 def imgSrc = attrs.remove("imgSrc") 176 def imgAlt = attrs.remove("imgAlt") 177 def img = "<img src=${imgSrc} alt=${imgAlt} />" 178 179 writer << "<th " 180 181 // process remaining attributes 182 attrs.each { k, v -> 183 writer << "${k}=\"${v.encodeAsHTML()}\" " 184 } 185 writer << ">${link(action:action, params:linkParams) { img } }" 186 // writer << body() 187 writer << "</th>" 188 } 189 127 190 } // end class
Note: See TracChangeset
for help on using the changeset viewer.