Question

in my project i am using the cgridview inside a modal window. now i am facing the problem that when i select the pagination the page get reloaded. how can i load the grid view with ajax pagination. my ui code id given below...

<div id="pick-category-modal" title="Pick Category" class="popupinfoholder2">
    <div style="width:700px; height:auto;">
        <?php
        $widget = $this->widget('zii.widgets.grid.CGridView', array(
            'id' => 'response-grid',
            'dataProvider' => $pickdataset->pickSection(),
            'cssFile' => Yii::app()->baseUrl . '/media/css/gridview.css',
            'summaryText' => '',
            'ajaxUpdate'=>true,
            'enablePagination' => true,
            'template' => '{items}',
            'pager' => array(
                'class' => 'LinkPager',
                'cssFile' => false,
                'header' => false,
                'firstPageLabel' => 'First',
                'prevPageLabel' => 'Previous',
                'nextPageLabel' => 'Next',
                'lastPageLabel' => 'Last',
            ),
            'columns' => array(
                .....................
                .....................
            ),));
        ?>
        <div class="grid-view-footer">
            <div class="paginationholder">
                <div id="pagination">
                    <?php $widget->renderPager(); ?>
                </div>
            </div>
        </div>
    </div>
</div>
Was it helpful?

Solution

Just testing this myself a moment ago, it appears that the pager kicked out with renderPager() does not work with the AJAX setting. The CGridView JavaScript only binds the AJAX to pagers inside the <div> rendered by the widget (#response-grid here), so it does not find and use your additional pager.

I just use the default pager that the CGridView renders at the bottom, and that works fine.

You could override the CGridView JS to fix this, or list it as an enhancement on the Yii bug tracker: http://code.google.com/p/yii/issues/list

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top