gridview如果在頁面的右側,左邊是一些菜單,當點擊頁面2時,它不僅刷新gridview,而且包括左邊部分的所有頁面都丟失 - -a全新的頁面出來幫忙〜點擊yii2 gridview linkpager的頁面跳轉錯誤
有調試截圖:
我的行爲是
public function actionList()
{
$model = new Loan();
$dataProvider = new ActiveDataProvider([
'query' => $model->find(),
'pagination' => [
'pagesize' => '1',
],
]);
return $this->renderPartial('list', ['model' => $model, 'dataProvider' => $dataProvider]);
}
我的看法是:
<?php
use yii\grid\GridView;
use yii\grid\SerialColumn;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\LinkPager;
?>
<?=GridView::widget([
'dataProvider' => $dataProvider,
'layout'=> '{items}{pager}',
'columns' => [
['attribute' =>'loan_type','label'=>'借款類型','options' => ['width' => '80']],
['attribute' =>'amount','label'=>'金額','options' => ['width' => '80']],
['attribute' =>'rate','label'=>'還款利率','options' => ['width' => '80']],
['attribute' =>'fee','label'=>'手續費','options' => ['width' => '80']],
['attribute' =>'status','label'=>'狀態','options' => ['width' => '80'] ],
['attribute' =>'comment','label'=>'審覈意見','options' => ['width' => '80']],
['attribute' => 'created_at','value' =>function($model){return date('Y-m-d',strtotime($model->created_at));},'label'=>'申請時間','options' => ['width' => '150']],
[
'class' => 'yii\grid\ActionColumn',
'header' => '操作',
'template' => '{audit}',
'buttons' => [
'audit' => function ($url,$model) {
return Html::a('<span id="xxxx" class="glyphicon glyphicon-user"></span>','#',['title'=>'審覈',
'onclick'=>"
$.ajax({
type: 'GET',
dataType: 'text',
url: 'http://182.92.4.87:8000/index.php?r=loan/pj', //目標地址
error: function (XMLHttpRequest, textStatus, errorThrown) {alert(XMLHttpRequest.status + ':' + XMLHttpRequest.statusText); },
success: function (page)
{
$('.ucRight').html(page);
}
});
return false;",
]);},
],
'urlCreator' => function ($action, $model, $key, $index) {
return Yii::$app->getUrlManager()->createUrl(['loan/list','id' => $model->status]);
},
'headerOptions' => ['width' => '80'],
],
],
]);
?>
沒有看到實際的代碼是不可能的。 – arogachev 2015-03-19 03:06:12
已更新,請再次參閱〜thx – aishuishou 2015-03-19 03:30:20
您是否希望在沒有頁面重新加載的情況下在'GridView'中分頁?爲什麼不爲了這些目的而簡單地使用內置的'Pjax'? – arogachev 2015-03-19 03:44:07