Move logic into a controller
Allow treetable options to be passed in