I try to get my model position inside dataProvider. I have a listview with pager:
Pjax::begin();
echo ListView::widget([
'dataProvider' => $dataProvider,
'itemOptions' => ['class' => 'item'],
'itemView' => 'tree_part',
'pager' => [
'class' => ScrollPager::className(),
'enabledExtensions'=> [ScrollPager::EXTENSION_SPINNER],
'spinnerSrc'=> Yii::$app->request->baseUrl.'/images/spinner.gif',
]
]);
Pjax::end();
I know i can access$model, $widget, $index in my partial view tree_part.php, but I cannot figure out how to get current $model index inside the data.
My dataprovider:
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort'=> ['defaultOrder' => ['creation_date'=>SORT_DESC]],
'pagination' => [
'pageSize' => 12,
],
]);
So if thepagesize is 12, $index variable will only show the value of 0-11. What I need is to get "global" index out of the total count of models.
Any advise would be highly appreciated.
Aucun commentaire:
Enregistrer un commentaire