Home > Backend Development > PHP Tutorial > 解决yii的CGridView在高级搜寻选项过多时点分页后php崩溃的情况

解决yii的CGridView在高级搜寻选项过多时点分页后php崩溃的情况

WBOY
Release: 2016-06-13 11:17:48
Original
812 people have browsed it

解决yii的CGridView在高级搜索选项过多时点分页后php崩溃的情况

倒导php崩溃是因为选项过多,其实为空的选项可以不用添加到分页的url上。


可以将以下代码放到views/layouts/main.php文件的底部,修正CGridView分页链接的地址。


<?php Yii::app()->clientScript->registerScript('pagerHref', "$(function(){    $('.pager a').each(function(){        var href = $(this).attr('href');        var page = href.match(/\/([\w]+)_page\/([0-9]+)/);        if (page != null) {            page = page[1]+'_page='+page[2];        } else {            page = '';        }        var sort = href.match(/\/([\w]+)_sort\/([\w]+)/);        if (sort != null) {            sort = sort[1]+'_sort='+sort[2];        } else {            sort = '';        }        var fields = $('.search-form form').serializeArray();        var data = '';        $.each(fields, function(i, field){            if (field.value != '') {                if (data == '') {                    data += field.name + '=' + field.value;                } else {                    data += '&' + field.name + '=' + field.value;                }            }        });        if (data != '' && page != '') {            page = '&' + page;        }        if ((data != '' || page != '') && sort != '') {            sort = '&' + sort;        }        var url = '".$this->createUrl($this->id.'/'.$this->action->id)."?' + encodeURI(data) + page + sort;        $(this).attr('href', url);      });});");?>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template