Solve the problem of php crash after paging of yii CGridView when there are too many advanced search options _ PHP Tutorial

Source: Internet
Author: User
Solve the problem of php crash after paging of yii CGridView when there are too many advanced search options. The reverse import php crashes because there are too many options. In fact, empty options do not need to be added to the paging url. You can put the following code at the bottom of the viewslayoutsmain. php file. The php crash caused by the correction of CGridVie is caused by too many options. In fact, empty options do not need to be added to the paging url.

You can put the following code at the bottom of the views/layouts/main. php file to correct the CGridView paging link address.

[Html]

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 );

});

});

");

?>

Bytes. You can put the following code at the bottom of the views/layouts/main. php file to correct CGridVie...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.