- Timestamp:
- Jan 29, 2010, 10:02:16 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/taglib/CustomTagLib.groovy
r290 r303 26 26 * this.assetSubItems = idList.collect { AssetSubItem.get( it ) } 27 27 * } 28 * 28 29 * Then a line in the controller: 29 30 * assetInstance.setAssetSubItemsFromCheckBoxList(params.assetSubItems) 31 * 32 * Fields: 33 * name - the property name. 34 * from - the list to select from. 35 * value - the current value. 36 * optionKey - the key to use. 37 * displayFields - (optional) available options are 'id' and 'name', defaults to the objects toString(). 38 * linkController - (optional, requires linkAction.) the controller to use for a link to the objects in the checkBoxList. 39 * linkAction - (optional, requires linkController.) the action to use for a link to the objects in the checkBoxList. 40 * 41 * Example: 42 * <!-- 43 * <custom:checkBoxList name="assetSubItems" 44 * from="${AssetSubItem.list()}" 45 * value="${assetInstance?.assetSubItems.collect{it.id}}" 46 * optionKey="id" 47 * displayFields="['id', 'name']" 48 * linkController="assetSubItemDetailed" 49 * linkAction="show"/> 50 * --> 51 * 30 52 */ 53 31 54 def checkBoxList = {attrs, body -> 32 55 … … 37 60 38 61 def displayFields = attrs.displayFields 62 def linkController = attrs.linkController 63 def linkAction = attrs.linkAction 39 64 40 65 def displayValue = " " … … 60 85 displayValue = " " 61 86 62 if( displayFields?.contains("id") ) {87 if( displayFields?.contains("id") ) 63 88 displayValue += obj.id + " - " 64 } 89 90 if(linkController && linkAction) 91 displayValue += "<a href=\"${createLink(controller: linkController, action: linkAction, id: obj.id).encodeAsHTML()}\">" 65 92 66 93 if(displayFields?.contains("name")) { … … 68 95 } 69 96 else displayValue += obj 97 98 if(linkController && linkAction) 99 displayValue += '</a>' 70 100 71 101 // if we wanted to select the checkbox using a click anywhere on the label (also hover effect) -
trunk/grails-app/views/assetDetailed/edit.gsp
r290 r303 89 89 value="${assetInstance?.assetSubItems.collect{it.id}}" 90 90 optionKey="id" 91 displayFields="['id', 'name']"/> 91 displayFields="['id', 'name']" 92 linkController="assetSubItemDetailed" 93 linkAction="show"/> 92 94 93 95 </td>
Note: See TracChangeset
for help on using the changeset viewer.