Refactor datagrid templates