Answer:
Praise be to Allah, the Lord of the World; and may His blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions.
Allah has mentioned the way of distributing the inheritance and fixed the shares of inheritors in a clear text of the Qur'an. Allah Says (interpretation of meaning) after declaring the shares of everyone:
{These are the limits (set by) Allâh (or ordainments as regards laws of inheritance), and whosoever obeys Allâh and His Messenger (Muhammad SAW) will be admitted to Gardens under which rivers flow (in Paradise), to abide therein, and that will be the great success. And whosoever disobeys Allâh and His Messenger (Muhammad SAW), and transgresses His limits, He will cast him into the Fire, to abide therein; and he shall have a disgraceful torment.} [4: 13-14].
The Prophet (Sallallahu Alaihi wa Sallam) said:
"Allah has determined a particular right for everyone, so the bequest made to an heir is not valid" [
al-Tirmizi ,
Abu Dawood , and
al-Syooti graded it as good].
Despite this Allah has permitted everyone to give his property in charity (as an endowment) as he likes in his lifetime to please Allah and get reward in his life and after his death. One is free to give his property as endowment to anyone regardless of whether the beneficiary is his relative or otherwise.
Therefore, the Waqaf (endowment) mentioned in your question is correct and valid for the poor grandchildren of the dead person. All grandchildren whether they are from his sons or daughters are liable to benefit from the endowment as long as there is no evidence that restricts the beneficiaries to the grandchildren from sons.
Know that the endowment is not valid if the person who made it specified that it be carried out after his death. It is rather considered as a bequest not an endowment. The Waqf becomes invalid if the Waqf property is not taken by the person to whom it is given before the property becomes liable to pay any indebtedness.
Also it becomes invalid if one does not take possession of the Waqf property before the death of the person who made endowment or before his death illness. As a general rule a will that exceeds one third of the inheritance is not valid.
The other properties would be distributed among the heirs of the dead person according to Sharia, not according to customs. If a person dies and leaves males and females then both of them will inherit from the dead person. The share of a male is equal to the shares of two females. It is forbidden for males to take more than their rights. If they do so, they commit a great sin and Allah will punish them except if they repent and give back the rights of other relatives.
Allah knows best.