Reputation: 1025
I used CArrayDataProvider
for grid in yii, the issue is with that it takes first whole data then it gives limit in data provider which is taking too much time to load, so i wants to do custom total count in arraydata provider, i did some stuff fot that but it is giving me error, here is my code
$rawDataWithArray = $modelMemberreceipt->getMemberReceiptListWithLimit($searchString,$PageSize,$currentPage);
$filteredData=$filtersForm->filter($rawDataWithArray);
$rawDataCount = $modelMemberreceipt->getMemberReceiptListItemCount($searchString);
$model = new CArrayDataProvider($rawDataWithArray, array(
'keyField' => 'ReceiptID',
'itemCount' => $rawDataCount,
'sort' => array(
'attributes' => array(
'ReceiptID','StoreName','member','LoyaltyCardNo','MerchantTypeID',
'ReceiptAmount','ReceiptDate','Status','Created','Updated','RejectionReasonCode','ProcessingReason',
'UpdatedBy','ScannedReceiptNo'
),
'defaultOrder' => $sortArray,
),
'pagination' => array(
'pageSize' => $PageSize,
'currentPage'=>$currentPage,
),
));
For $rawDataWithArray i set the limit so it will give records like 10, for $rawDataCount i set the total count, for both the variable i am getting the proper data so no issue with the data, when i set the itemCount it is giving me error Property "CArrayDataProvider.itemCount" is read only.
, can anyone please tell me how can i resolve this issue ?
Upvotes: 1
Views: 1380
Reputation: 4313
itemCount
Returns the number of data items in the current page. It will be calculated autamaticaly.
I think you need to set totalItemCount
instead of itemCount
:
'totalItemCount' => $rawDataCount,
http://www.yiiframework.com/doc/api/1.1/CArrayDataProvider
Upvotes: 1