Drilldowns Plugin
Dependency :
compile ":drilldowns:1.6"
Summary
Description
Drilldowns Plugin
Description
The drilldowns plugin allows a user to drill down from a summary level screen to a more detailed level. For example, from a list of authors to a list of books by the selected author. It works by controller and action - usually the 'list' action. Each controller/action combination may only appear once within the drilldown stack, whether as the 'drill from' list or the 'drill to' list. Any list page can be both a 'drill from' and a 'drill to' page thus allowing the creation of the 'stack' of drilldowns.Installation
Execute the following from your application directory:grails install-plugin drilldowns
Usage
The components of the plugin are in a package called org.grails.plugins.drilldown and any class that wishes to access the components directly must include the following:import org.grails.plugins.drilldown.*<td><g:drilldown controller="book" action="list" value="${authorInstance.id}"/></td>
- controller - The name of the 'drill to' controller.
- action - The name of the 'drill to' action (defaults to 'list')
- domain - If the 'drill from' controller name is NOT in the format domainController then you must identify the domain being drilled from (e.g. domain="Author"). Defaults to the controller name capitalized to make it a domain name.
- value - The id of the 'drill from' instance that the 'drill to' display is to be limited to.
- text - Any text to display as the drilldown link. Default is no text. If text is supplied then, by default, this would stop the automatic display of any image.
- encodeAs - How to encode any text attribute e.g. encodeAs='HTML'. Default is no encoding (thus allowing HTML markup to be included).
- image - If set to true, forces the display of the default image even when a text attribute exists. When set to a URL, uses the image at that URL (even if there is also text).
- imageAfter - When both text and an image are to be displayed within the drilldown link, specifies whether the image is to be displayed before (false) or after (true) the text. The default is after (true).
def drilldownServicedef list = {
params.max = Math.min(params.max ? params.int('max') : 10, 100) def ddAuthor = drilldownService.source(session, params, "author.list")
def ddPub = drilldownService.source(session, params, "publisher.list") [bookInstanceList: Book.selectList(session, params),
bookInstanceTotal: Book.selectCount(session, params),
ddAuthor:ddAuthor, ddPublisher:ddPub]
}drilldownService.source(session, params, "author.list", [domain:"Book"])
drilldownService.source(session, params,"author.list", [property:"reviewAuthor"])
drilldownService.source(session, params, "author.list", [domain:"Book", property:"reviewAuthor"])
<g:if test="${ddAuthor}"> <h1>Book List for Author: ${ddAuthor.name} <g:drilldownReturn/></h1> </g:if> <g:elseif test="${ddPublisher}"> <h1>Book List for Publisher: ${ddPublisher.name} <g:drilldownReturn/></h1> </g:elseif> <g:else> <h1><g:message code="default.list.label" args="[entityName]" /></h1> </g:else>
def create = {
def bookInstance = new Book()
bookInstance.properties = params
bookInstance.author = drilldownService.source(session,
[controller: params.controller, action: "list"], "author.list")
return [bookInstance: bookInstance]
}