Created
January 26, 2009 17:45
-
-
Save rhyolight/52882 to your computer and use it in GitHub Desktop.
Making Grails-UI dataTable parent-child relationship
This file contains 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
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'); | |
GRAILSUI.replaceWithServerResponse(resultsDiv, o); | |
} | |
YAHOO.util.Dom.removeClass('childPanel', 'hidden'); | |
}, | |
failure: function(o) { | |
alert('child table render error: ' + o.responseText); | |
} | |
}; | |
var renderChildTable = function(parentId) { | |
YAHOO.util.Connect.asyncRequest('POST', '${createLink(controller:'myController',action:'populateChildTable')}', childTableRenderCallback, {'parentId'=parentId}); | |
}; | |
GRAILSUI.parentTable.subscribe('rowClickEvent', function(e) { | |
var selectedRows = this.getSelectedRows(); | |
var parentId = this.getRecord(selectedRows[0]).getData().id; | |
renderChildTable(parentId); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment