The creature who used the spell dimension door [conj] (PH 221) is free of the grapple. The spell's Target entry reads, "You and touched objects or other willing creatures," but the spell's text clarifies that the caster "may also bring one additional willing Medium or smaller creature... per three caster levels."
That may in there means he doesn't have to, so the creature can totally leave that grapple-lap behind.
Note that casting a spell in a grapple requires a Concentration skill check (DC 20 according to PH 70, or DC 20 + spell level according to PH 156 and 170), and even then the spell can't have somatic components and material components the spell requires must be in hand when the grapple's started. Fortunately, the spell dimension door only requires verbal components.
If the creature using dimension door wants to take the grappling foe with it, it must touch the foe (this is part of casting the spell if the foe is willing--PH 174), and the foe must be willing to go. If the foe chooses, the foe makes a Willpower saving throw to negate the effect. If the foe succeeds on that saving throw, the foe doesn't go, the creature does, and the grapple ends. If the foe goes with the creature, it's up to the DM whether the grapple ends or continues (I'd argue the latter).