I am using CGridView to generate a table whose data is received by a call to a stored procedure. To supply the data provider I am using the CArrayDataProvider like this
$custdata = new CArrayDataProvider($rawdata, array(
'totalitemCount' => $total,
As I only get the current page data in $rawdata, how can I specify that this is the only data available. I have tired using ‘currentPage’ in ‘pagination’ but that doesn’t work.
I have a work around by pre-appending a null array like
if($page!=1) $rawdata = array_merge(array_fill(0,($page-1)*$size,null),$rawdata);
But this seems a common problem and doesn’t Yii have something I am missing.
what do you mean by "this is all data available"?
pagination gets data count and do the pagination…
Not want it to show all the data you give? don’t give it
Lets take for example I have data only for the 4th page. Now CArrayDataProvider expects the rawdata to be the entire set. So to work around it I had to prefill the first three pages data with null. I felt it would have been easier if the CArrayDataProvider had a paramter using which I can specify that only one pages data is available and the page number.
You can’t expect from ArrayDataProvider to know about data that not exists
If you want to give it data via some hacky way - hack CArrayDataProvider…
just extend it, and rewrite what you need