Skip to content

Instantly share code, notes, and snippets.

@rhyolight
Created January 26, 2009 17:45
Show Gist options
  • Save rhyolight/52882 to your computer and use it in GitHub Desktop.
Save rhyolight/52882 to your computer and use it in GitHub Desktop.
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');
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