2014-11-18 3 views
1

[SOLVED] У меня есть страница с Cgridview.yii cgridview afterAjaxUpdate не работает на пейджере

AfterAjaxUpdate запускается один раз, когда страница загружается, но не далее.

$this->widget('zii.widgets.CGridView', array(
     'id' => 'Ticket-grid', 
     'ajaxUpdate'=>true, 
     'afterAjaxUpdate'=>'js:console.log("test")', 
     'dataProvider' => $model->search(), 
     'template' => "{items}{summary}{pager}", 
     'itemsCssClass' => 'table table-bordered table-condensed', 
     'filter' => $model, 
     'columns' => array(// etc 

AfterAjaxUpdate не работает для фильтрации или обновления страниц.

Также нет ошибок в консоли.

РЕШЕНИЕ ::

$this->widget('zii.widgets.CGridView', array(
    'id' => 'Ticket-grid', 
    'ajaxUpdate'=>true, 
    'afterAjaxUpdate'=>'function(id,data){YourFunctionName()}', 
    'dataProvider' => $model->search(), 
    'template' => "{items}{summary}{pager}", 
    'itemsCssClass' => 'table table-bordered table-condensed', 
    'filter' => $model, 
    'columns' => array(// etc 

ответ

1

Попробуйте добавить селектор обновления.

$this->widget('zii.widgets.CGridView', array(
     'id' => 'Ticket-grid', 
     'ajaxUpdate'=>true, 
     'afterAjaxUpdate'=>'js:console.log("test")', 
     'dataProvider' => $model->search(), 
     'template' => "{items}{summary}{pager}", 
     'itemsCssClass' => 'table table-bordered table-condensed', 
     'filter' => $model, 
     'updateSelector'=>'custom-page-selector', //update selector 
     //^^^^^^^^^^^^^ 
     'columns' => array(// etc 
+0

Хорошо работает. Хотелось бы, чтобы страница не загружалась, поскольку добавляет запрашиваемую страницу в URL-адрес. Обычно мы обновляем страницу, чтобы вернуться на первую страницу, так как их около 60 страниц. Я добавлю пользовательский css, чтобы поставить статическую кнопку первой страницы на пейджер. – Chris

+0

Оформить заказ. @ProgrammingStudent – Chris