Hello Ali,
You could collapse/expand the detail template using the API of the Grid widget - collapseRow / expandRow.