entity reference view in a view I have 2 content types: location and maintenance.

I would like a view that shows all the locations with a search box at the top so the user can search the right location; when users click on a location, they are redirected to the location details and the maintenance nodes listed under the location details.

So the workflow is like this:


Search the location 
Click on the location
See a view with location and maintenance nodes


I have already installed entity reference and made references from maintenance to locations, but I just can't get the view settings right; a list of all the locations is what I am getting, so far.
Your existing view listing all locations is fine for now (assuming a path like "/locations"). Create another display in that view (or a complete different view if you want). This second display/view should first get a relationship to the (location) entity referenced by the field "location". Then the view should have a contextual filter on a node id using that relationship; argument should be in the URL, e.g. by using something like "/locations/%/maintenance" as path.

So if you have two locations (nids: 1 + 2) and 4 maintenance nodes (nids: 3-6), you should see all locations at "/locations" and all maintenance for the first location at "/locations/1/maintenance". Now you just need to link from the first view to the second one by using the correct path "/locations/[nid]/maintenance" and it should be the way you want it. You can take it a step further by displaying all locations along with the maintenance on a single page. You'll need an additional module (if not yet installed): views_field_view.

If that is installed, you can proceed to the next step and include the maintenance view in the location view. Add two new fields, first of type "Content: Nid" and second of type "Global: View". For the latter field choose the maintenance view in the dropdown and enter "!nid" in the argument textbox. By doing this, the current nid of the location is send as an argument to the maintenance view and thus only displaying maintenance nodes that are connected to that current location.