trejder
(Tomasz)
October 18, 2023, 8:50am
1
Can I (and, if yes then how to achieve this) inject something opposite to the paginator used by GridView?
I think that this place would be fabulous for placing dropdown allowing user to select how many items are rendered per page:
But, since I am a total newbie around DOM selectors, I have no idea how to inject i.e. dropdown to inside nav#w1
and how to make it float right, so it would land directly opposite the paginator?
Any help, tips or thoughts are highly encouraged. Thank you.
BartQ76
(Bartek)
October 18, 2023, 4:58pm
2
Live example from my project, with some visual enhancements for clarity here.
It works with extended LinkPager class and Bootstrap grid system https://getbootstrap.com/docs/4.0/layout/grid/#how-it-works
The trick is to embed the widget output into grid system mentioned above (8+4 = 12 columns in total).
In gridview config:
'pager' => [
'class' => '{yournamespace}\LinkPager', // Overridden class
And the class itself:
class LinkPager extends \yii\bootstrap5\LinkPager {
public function beforeRun() {
if (!parent::beforeRun()) {
return false;
}
echo Html::beginTag('div', ['class' => 'container']);
echo Html::beginTag('div', ['class' => 'row']);
echo Html::beginTag('div', ['class' => 'col-8 bg-info']); // Left column width
return true;
}
public function afterRun($result) {
$result = parent::afterRun($result);
$out = $result;
$out .= Html::endTag('div'); // column
$out .= Html::tag('div', "Your content. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
, ['class' => 'col-4 bg-secondary']); // Right column width
$out .= Html::endTag('div'); // row
$out .= Html::endTag('div'); // container
return $out;
}
}
The result:
1 Like
trejder
(Tomasz)
October 19, 2023, 7:30pm
3
Marvelous! And from the first sight at your code and screenshot, it looks exactly like the thing that I need.
One last quick question. Do we have any Bootstrap 5- or Yii 2- combo-like or drop-down-like component that would use Bootstrap styles and could like as close to the LinkPager styling as possible?
guri
(Gunnar Rikardsson)
October 21, 2023, 8:31am
4
1 Like
trejder
(Tomasz)
October 21, 2023, 5:19pm
5
Yes, this is exactly what I am looking for, thank you!
I don’t know, how did I manage to not find this myself? :[