Dynamically Adding Filter Buttons According to Groups in Store

I'm looking to have a button appear for every group in my store. The button would filter the grid below to show only that group. I know how to pull the group names from the store and get them into an array but is there a way to dynamically create buttons, each with their own action function, and add them to the grid?

Any general advice on how to go about doing this would be much appreciated