Cactivedataprovider - Pagination Problem When Using 'group' And 'with' In Criteria

Please help me to solve this problem/bug: Pagination don’t work in TbGridView/CActiveDataProvider, incorrect count of total results when using ‘group’ and ‘with’ in criteria.

I read this

and this

After applying luk1999 solution…pagination list are incorrect page one show 4 records, page two 9 records, page three 9 records, page four 1 record, why?