Created
July 7, 2009 18:19
-
-
Save 3gcodes/142261 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def gridList = { | |
| Integer page = Integer.parseInt(params.page) | |
| Integer rows = Integer.parseInt(params.rows) | |
| Integer numRecords = Color.count() | |
| Integer totalPages = 0 | |
| if (numRecords > 0) { | |
| totalPages = Math.ceil(numRecords / rows); | |
| } | |
| if (page > totalPages) { | |
| page = numRecords; | |
| } | |
| Integer limit = rows * page - rows; | |
| if (limit < 0) limit = 0; | |
| def colors = Color.createCriteria().list() { | |
| and { | |
| if (params.name) { | |
| like("name", "%${params.name}%") | |
| } | |
| if (params.description) { | |
| like("description", "%${params.description}%") | |
| } | |
| } | |
| maxResults(rows) | |
| firstResult(limit) | |
| order("${params.sidx}", "${params.sord}") | |
| } | |
| colors = colors.collect { | |
| [cell: [it.name, it.description], id: it.id] | |
| } | |
| def jsonColors = [page: "${params.page}", records: rows, rows: colors, total: totalPages] | |
| render jsonColors as JSON | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment