Added subDoc/refDoc mode for sub-datagrid

Simplified code tpl data type helper.