我正在尝试在yii1.1的grideview
中创建一个链接,其中包含id和它的前后元素id。
array(
'class' => 'bootstrap.widgets.TbButtonColumn',
'template' => '{manage}',
'buttons' => array(
'manage' => array(
'label' => 'Manage',
'icon' => 'th',
'url' => Yii::app()->createUrl(
"/member/data/manage",
array("id" => $data->id, "prev" => ???, "post" => ???)
),
),
),
),
答案 0 :(得分:0)
尝试下面的代码,不是很好的解决方案,但应该工作
array(
'class' => 'bootstrap.widgets.TbButtonColumn',
'template' => '{manage}',
'buttons' => array(
'manage' => array(
'label' => 'Manage',
'icon' => 'th',
'url' => function ($data, $row, $widget) {
$pagination = $widget->grid->dataProvider->getPagination();
$widget->grid->dataProvider->setPagination(false);
$provider_data = $widget->grid->dataProvider->getData();
$widget->grid->dataProvider->setPagination($pagination);
return Yii::app()->createUrl(
"/member/data/manage",
array(
"id" => $data->id,
"prev" => isset($provider_data[$row - 1]) ? $provider_data[$row - 1]->id : '',
"post" => isset($provider_data[$row + 1]) ? $provider_data[$row + 1]->id : ''
)
);
},
),
),
),