Question

I use Sphinx to generate a list of needed ID's. On this list of ID's I apply filters using the Sphinx language and then I create and return a new CActiveDataProvider using the Search Model method;

image example

$dataProvider = new CActiveDataProvider('model', array(
                    'criteria' => $criteria,
                    'pagination' => array(
                        'pageSize' => $this->pageSize,
                        'currentPage' => $this->cp_page - 1,
                    ),
                ));

In the view, now, I have:

<div class="search_result searchconright">
         <?php

                 $custom_pager_left = '
                <div class="pagetxt">

                <ul class="searchPager">
                    <li><span>View</span></li>
                    <li class="page"><a href="" class="page_search_limit">All</a></li>
                    <li class="page"><a href="" class="page_search_limit page_search_limit_active">3</a></li>
                    <li class="page"><a href="" class="page_search_limit page_search_limit_active">5</a></li>
                    <li class="page"><a href="" class="page_search_limit page_search_limit_active">24</a></li>
                    <li class="page"><a href="" class="page_search_limit">48</a></li>
                </ul>

                </div>
            ';

        $this->widget('zii.widgets.CListView', array(
            'ajaxUrl' => Yii::app()->createAbsoluteUrl('/employer/search'),
            'id'=>'listViewSearch',
            'dataProvider' => $model->search(),
            'template' => "{summary}\n{sorter}\n{items}\n<div style='float:left;width=700px;'>$custom_pager_left<div class='pagetxt'>{pager}</div></div>",
            'itemView' => '_index_post',
            'enablePagination' => true,
            'pager' => array(
                'cssFile' => Yii::app()->baseUrl . '/css/clistview.css',
                'header' => false,
                'firstPageLabel' => 'First',
                'prevPageLabel' => 'Previous',
                'nextPageLabel' => 'Next',
                'lastPageLabel' => 'Last',
            ),
            'summaryText' => '',
            'sortableAttributes' => array(
            ),
        ));
        ?>
    </div>

But this fails to work correctly, because if i click next, and the list end's, somehow, the ajax code does not reinitialize the url that is being send, it keeps on to concat with the old url until the url gets so big that the app crashes.

Shouldn't CListView verify if the data received exists? Sphinx could give a ID of a registration, that is no more there or inactive;

What's happening and how can i prevent this?

Was it helpful?

Solution

I found forum topic with some issues with ajaxUrl property and pagination. It looks like ajaxUrl is ignored by pagination. Weird, maybe thats the problem.

Here is this topic: http://www.yiiframework.com/forum/index.php/topic/21886-problem-with-clistview-and-ajaxurl-property/

Notice that at last posts route is set on dataprovider rather than listview. Internally listview, or grid view, should pass ajaxUrl into dataprovider.

Here is how to manually setup route for pagination: http://www.yiiframework.com/doc/api/1.1/CPagination#route-detail

$dataprovider->pagination->route = 'site/index';

Also manually set params for pagination if some are used (including does coming with $_GET): http://www.yiiframework.com/doc/api/1.1/CPagination#params-detail

$dataprovider->pagination->params = array('search' => 'Search string');

Im also not sure how $custom_pager_left link hrefs should be set?

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