fixes bug 918929 - can't sort columns in reports view

@rhelmer @AdrianGaudebert r?

I can't believe I missed this. Basically, the certain things we did in `$(function() { ...` now has to be done after the HTML has been loaded by AJAX. 

Also, we can't hard-code specific fields for custom sorting on the Reports tab. That's why I loop over the `<th>` tags.