This is a challenge and also a comprise especially if they are part of the daily / regular child care activities. If the grandparents (aka 'grands') are not regularly involved, then it is a different challenge obviously.
My parents were part of the daily regime from the time he was 10 mths old (anywhere from 3 - 5 days a week)until we moved him into SK on 5 full days in his daycare facility. And now provide afterschool care for him now he's in Grade 1.
This is what has worked for me (my son is 6 yrs old) but it needs to be tailored to the age of the child and their maturity (more so in the past 2 years than previously):
1) set the ground rules for the child and indicate to the child they are the same as home (if they can read, write it out and leave it somewhere where the kids can see it at the grands to remind them)
2) upon unacceptable behaviour, the child is to understand that they will get disciplined at when you pick them up (ie. time-out/etc.) or at home if the 'grands' does not do the disciplining or want to do it
3) ask the 'grands' to relay to you what behaviour the child has had when you pick them up. -good and bad.
4) understand what has caused the unacceptable behaviour (unfortunately sometimes it's the grandparents who instigate it) and explain to them why they shouldn't have done this (and how they need to respect other people). if timeout is part of your disciplining, have a special place for that at the grands as well and use it well
5) have them apologize to the 'grands' before you leave for their specific unacceptable behaviour
NOTE: it really helps that if you do the disciplining in front of the grands and the grands will interfere the first few times as the child will throw a fit as they don't want the grands to see them in trouble. but after a while, the grands will see that your method works and will stay out of the way when this is happening.
Otherwise, the following are items that I found you need to have some level of compromise:
-TV time, there is no way to win this one. as long as the programming is suitable, don't quibble too much as much of the programs are educational at one level or another (for the 5 & under crowd). Just make it understood that if the child watches too much at the grands, they won't get much / if any tv time when they get home.
- meals, we always made and packed meals for our son to take to the grands when he was there on a more daily basis so 1) the grands didn't have to think of what they needed to feed the kid 2) this is food you know the kid will eat. You've got the fastfood/junkfood to think about too. Keep this consistent as home and if they get it at the grands, then they won't get any at home/weekend, etc.
On the other hand, things I feel that should not be compromised on, are items such as high priced items (electronic games and computers) and playing games / computer time. Explain carefully that these are not acceptable gifts unless it is a special occasion such as Christmas/birthday/etc (& they should consult with you prior to gifting) as the child will then expect gifts everytime they visit (especially where the grandparents are not involved on a daily basis) and not just want to spend quality time with them. RE: computer time, if they get it at the grands, then they don't get it at home.. Things you may want to overlook are smaller priced gifts such as puzzels, board games that can be left at the grands for their next visit.
And the biggest thing to do is 'bite your tongue' on smaller issues and 'pick your fights' (vent all you want at home, but keep quiet when you are there). Especially if you need the grands on daily / regular basis for childcare.
As you can tell, I'm have very strong feelings on this topic and hopefully you'll work things out in your own way that works for you.