Skip to content

Instantly share code, notes, and snippets.

View rhyolight's full-sized avatar

Matthew Taylor rhyolight

View GitHub Profile
@rhyolight
rhyolight / gist:51792
Created January 25, 2009 14:13
How Grails-UI turns groovy data structures into JavaScript data structures.
/**
* Turns map into a javascript config object string for YUI. This is what allows configurations passed into the
* grailsUI tag to be passed along to the YUI widget.
*/
def mapToConfig(attrs) {
attrs.collect { key, val ->
// if this is a handler, the val will be a javascript function, so don't quote it
if (key == 'handler') return "$key: $val"
"'$key': ${valueToConfig(val)}"
}.join(",\n")
@rhyolight
rhyolight / gist:52882
Created January 26, 2009 17:45
Making Grails-UI dataTable parent-child relationship
YAHOO.util.Event.onDOMReady(function() {
var childTableRenderCallback = {
success: function(o) {
if (o.responseText !== undefined) {
// kill off any existing data tables to manage memory
if (GRAILSUI.childTable != undefined) {
GRAILSUI.childTable.destroy();
}
var resultsDiv = document.getElementById('childPanel');
var renderChildTable = function(parentId) {
GRAILSUI.childTable.customQueryString = 'id=' + myParentId;
var newState = {
startIndex: 0,
sorting: { // Sort values
key: 'id', // or whatever you want the default sort on
dir: YAHOO.widget.DataTable.CLASS_ASC
},
@rhyolight
rhyolight / gist:54078
Created January 28, 2009 17:22
Grails-UI menubar example markup for version 1.1
<gui:menubar>
<gui:menuitem url='http://example.com'>Example</gui:menuitem>
<gui:submenu label='Foodstuffs'>
<gui:menuitem url='http://campbells.com'>Campbell's Soup</gui:menuitem>
<gui:menuitem url='http://cheetos.com'>Cheetos</gui:menuitem>
<gui:menuitem url='http://guiness.com'>Guiness</gui:menuitem>
</gui:submenu>
<gui:submenu label='Shoes'>
<gui:menuitem url='http://nike.com'>Nike</gui:menuitem>
<gui:menuitem url='http://reebok.com'>Reebok</gui:menuitem>
@rhyolight
rhyolight / gist:54094
Created January 28, 2009 17:27
Grails-UI example of a menu component
<gui:menu id='myMenu'>
<gui:menuitem url='http://example.com'>Example</gui:menuitem>
<!-- Grouped and titled -->
<gui:menugroup title='Foodstuffs'>
<gui:menuitem url='http://campbells.com'>Campbell's Soup</gui:menuitem>
<gui:menuitem url='http://cheetos.com'>Cheetos</gui:menuitem>
<gui:menuitem url='http://guiness.com'>Guiness</gui:menuitem>
</gui:menugroup>
<!-- Grouped, no title -->
<gui:menugroup>
@rhyolight
rhyolight / gist:54917
Created January 30, 2009 03:20
Grails-UI DataTable with inline cell editing
<gui:dataTable
draggableColumns="true"
id="dt_3"
columnDefs="[
[id:'ID', formatter:'text', sortable:true, resizeable: true],
[name:'Name', formatter:'text',
editor:[controller:'demo', action:'tableChange', config:[disableBtns:true]],
sortable:true, resizeable: true],
[birthDate:'Birth Date', formatter:'date',
editor:[controller:'demo', action:'tableChange', config:[disableBtns:true]],
@rhyolight
rhyolight / gist:54939
Created January 30, 2009 04:22
Grails-UI Line Chart Example
<div id='lineChart' style="width:600px; height: 400px"></div>
<gui:lineChart
renderTo="lineChart"
data="[
[ month: 'January', rent: 880.00, utilities: 894.68 ],
[ month: 'February', rent: 880.00, utilities: 901.35 ],
[ month: 'March', rent: 880.00, utilities: 889.32 ],
[ month: 'April', rent: 880.00, utilities: 884.71 ],
[ month: 'May', rent: 910.00, utilities: 879.811 ],
@rhyolight
rhyolight / gist:54941
Created January 30, 2009 04:25
Grails-UI Bar Chart Example
<div id='barChart' style="width:600px; height: 400px"></div>
<gui:barChart
id='myBarChart'
renderTo="barChart"
data="[
[ year: 2003, revenue: 1246852, expense: 1123359, income: 123493 ],
[ year: 2004, revenue: 2451876, expense: 2084952, income: 366920 ],
[ year: 2005, revenue: 2917246, expense: 2587151, income: 330095 ],
[ year: 2006, revenue: 3318185, expense: 3087456, income: 230729 ]
@rhyolight
rhyolight / gist:54942
Created January 30, 2009 04:28
Grails-UI Column Chart Example
<div id='columnChart' style="width:600px; height: 300px"></div>
<gui:columnChart
id='myColChart'
renderTo="columnChart"
data="[
[ month: 'Oct', pork: 1354, beef: 1442 ],
[ month: 'Nov', pork: 1326, beef: 1496 ],
[ month: 'Dec', pork: 1292, beef: 1582 ],
[ month: 'Jan', pork: 1387, beef: 1597 ],
@rhyolight
rhyolight / gist:54943
Created January 30, 2009 04:30
Grails-UI Pie Chart Example
<div id='pieChart' style="width:600px; height: 400px"></div>
<gui:pieChart
renderTo="pieChart"
data="[
[ response: 'Summer', count: 564815 ],
[ response: 'Fall', count: 664182 ],
[ response: 'Spring', count: 248124 ],
[ response: 'Winter', count: 271214 ],
[ response: 'Undecided', count: 81845 ]