Iniside a view, I have a relationship set up between two tables: departments and employees. I want to use a view to display it in the following format:
Department A | Department B | Department C
Employee 1 Employee 5 Employee 6
Employee 2 Employee 7 Employee 8
Employee 3
Employee 4
But until now, using the grid and table style, I'm only able to display it as follow:
Department A
Employee 1
Employee 2
Employee 3
Employee 4
Department B
Employee 5
Employee 7
Department C
Employee 6
Employee 8
I know I could create a module or a block for this but I would prefer to leave it inside a view and enable our client to change it whenever he wants to. How would you solve this requirement? Is there a view hook that would allow me to access the data and wrap my HTML table around it?
You can do it by making it "a view in a view". The basic view is a view of departments, set to display in a grid, with 3 grids per page. It will have 2 fields - department title field, and a field containing the view of employees. How do you put a view as a field? I suggest you use the Views Customfield module set to PHP and calling the list of employees with views_embed_view($name, $display_id)
.