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 https://github.com/yiisoft/yii/issues/167

and this http://www.yiiframework.com/forum/index.php/topic/20910-cactivedataprovider-cdbcriteria-pagination-count-doesnt-match-number-of-records/page__p__147968#entry147968

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?

Tnx.