To retrieve the selected records of a subgrid in dynamics crm 2011 just write down below code in your javascript function.
var accountContactsGrid= document.getElementById("accountContactsGrid").control; var selectedids = gridControl.get_selectedIds();