I posted a similar thread about my grandson in ‘grandparenting’, he is only two and rejected me in order to play with grandpa, but have heard it can happen with older children.
I am giving it time and when it was his second birthday I won him over with a game in the garden, he really loved it and after that wouldn’t leave me alone but he is so fickle I could be persona non grata again the next time we visit. Grandpa has never been out of favour.
Next time arrange to play a game with teams so you are with one child and grandpa is with the other, even if it is just a case of batting a ball to each other without dropping the ball. But don’t try too hard, that was good advice for me, just give it time and be kind and understanding with them, in a little while am sure you will be more included.
All the best.