Marrying a grandfather's ex-wife after he divorced her is Haram (prohibited), because Allah (Exalted be He) says:
And marry not women whom your fathers married
The "fathers" in this Ayah (Qur’anic verse) include grandfathers. Accordingly, this marriage is not lawful and it is obligatory on the husband to halt his relations with this woman and separate from her. As to the children from this marriage, they are attributed to the husband because he was ignorant of the ruling. (Part No. 18; Page No. 208) May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.