All 50 states currently have some type of "grandparent visitation" statute through which grandparents, and sometimes others (foster parents and stepparents, for example), can ask a court to grant them the legal right to maintain their relationships with their grandchildren. But state laws vary greatly when it comes to the crucial details, such as who can visit and under what circumstances. And the courts give great deference to a parent's decision to limit grandparent visitation.
Approximately twenty states have "restrictive" visitation statutes, meaning that generally only grandparents can get a court order for visitation -- and only if the child's parents are divorcing or if one or both parents have died. States with more permissive visitation laws allow courts to consider a visitation request even without the death of a parent or the dissolution of the family, so long as visitation would serve the best interests of the child.
For more information on challenges to permissive grandparent visitation statutes, see Nolo's article Grandparent and Caretaker Visitation Rights.