Question: In spoken conversations the grammar used is sometimes very different from the rules that we learn in textbooks or that apply to writing. This is even more so in regional dialects when sentences like

> 
> Das ist der Erich, dem wo seine Frau davongelaufen ist.
> 
> 
> 

are perfectly understood and spoken just like above.

How do we prepare to differentiate a regional grammar from official grammar rules when traveling to Germany?

Answer: 
It is not “wrong”. You might think that anything goes, but this kind of construction has to be very specific to pass as “locally correct”. If you don’t want to learn a particular dialect, you should speak with lots of different people which is a good idea in any case. But you will always pick up something local. There is no “pure” language.

So, my advice:

Speak with lots of different people.

Seek out situations that favour less use of dialect. (So maybe not in a village bar.)

Ask your native friends to take into account your need to learn regular grammar and tone down the local variants.
I can imagine that it's really hard to learn German grammar (and pronunciation) from native speakers. Most of the regions in German speak a very unique and strong dialect – even when travelling only a few miles.

The only thing that I can suggest, is to let people know that you're not from Germany, but want to learn German. Most of them will at least try to speak standard German.

You might also want to think of specific regions where the dialect is closer to the standard. I would suggest the North of Germany, Baden-Württemberg or Hesse. The dialects are much like the High German (although the pronunciation might not be).

*PS: That answer is probably a bit biased. I am from the Saarland (a German Federal State) and its dialect is probably one of the more extreme forms. That's why I am not totally reliable when it comes to German dialects. ;)*