When little kids (and big kids) behave very well for others and poorly for parents, it means they still have some sense that their parents care, and are still afraid of what others might do -- it's a trust thing. That means, at present, your little guy still trusts you to help him get his needs met (which is why he's whining, he is needing something and doesn't know how to get it, it's possible that so far whining is the only thing that's working sometimes). He doesn't (clearly) trust his grandma, so he is careful and 'good' around her, out of genuine fear for his survival. He can't predict what she might do if he doesn't do what she expects, because he doesn't know her well enough. Exactly the same thing would have happened if he'd been cared for by some woman down the street that he'd never met before, or even Hannible Lechter. Who the other person is has nothing to do with it -- it's just fear that keeps them quiet and 'good.'
Most 18mo boys are not into snuggles and want to explore their worlds. Their worlds need to be made safe, loving and warm in order for that exploration to feel free and so he can engage with it in appropriate (safe) ways, without constantly being told to be other than he is (inquisitive, curious, pre-verbal).
You can tell him to use his words until your eyebrows fall off, but until his brain grows more and he actually gains more vocabulary, he remains incapable of doing so -- even for bribes, threats, begging or pleading. It is a great deal of pressure to put on a small brain: doing things it is not yet capable of doing. You can't speed it up, but you can smooth it out. The more stress he feels, the slower his development will be... meaning his ability to speak well will be pushed further and further into the future.
Get to know him very well, anticipate what he'll be curious about and make it easy for him to explore it all safely or just make it unavailable. He does not 'need to learn' that some stuff is not for playing with -- by the time he has any use for the information, he'll be long past this stage. It is not logical that some knobs and dials and hard and soft objects are alright to play wiht and some are not -- it simply doesn't make any sense to him. He is trying to make sense of his world, and unless you're on his level, you will have a great deal of difficulty understanding what he's trying to do, and you will very often make mistakes about his motives. He isn't trying to break things (although it's easier to see how things are made by taking them apart -- a reality for many boys that never really goes away, which is why they make good engineers and mechanics), he's trying to understand them.
He isn't trying to drive you nuts by whining at you, he's trying to get his needs met. Not his whims, not his desire to control you and everything else in the universe -- his needs. They are legitimate and they will not go away until they are met. Like hunger: The NEED for attention (which is parallel to the need for survival in small children) does not go away because a meal was skipped and there isn't food for another one. The need for attention today doesn't go away because he had lots yesterday, anymore than his need for dinner will be here again this evening, even though he's had dinner every day for a week already.
Oh, and btw: your mil telling you that he was wonderful for her IS a criticism of you, and a giant, needy, obnoxious pat on the back for her own skill and talent as a parent-stand-in. Isn't that nice?