Changes for #2516
Fixes #2516 CGridView problem with customtemplates