If both parents are denying grandparents access to the child, there is little a court can or will likely do.
More commonly, it’s only one parent who wants to block grandparent access and the other parent consents to the visitation. In that scenario, the grandparents can seek a court order giving visitation. For the court to grant such access, the grandparents would need to show a long and continuing relationship with the child and that continuing contact is in the best interest of the child.
What can also happen is that the court will order the grandparents to see the grandchild during the time that the grandparents’ child has custody of the grandchild.