Custom yii cgridview and clistview Components

Source: Internet
Author: User

How to set common attributes:

Example:

$this->widget('zii.widgets.CListView', array('dataProvider'=>$book->search(),'itemView'=>'_book','pager'=>array('class'=>'CLinkPager','header'=>'Visit to page','firstPageLabel'=>'<<','prevPageLabel'=>'<','nextPageLabel'=>'>','lastPageLabel'=>'>>',)));

When we need to process a specific _ view of an iteration, we can use the $ index variable for some logic processing, so that we can better modify layout and so on.

<!-- inside your CListView's itemView partial --><div class="<?= ($index % 2) ? 'odd' : 'even' ?>">...

Then, process in CSS:

.odd {background:yellow;}.even{background:gray;}

Of course, there is also a walk around method that can achieve the same effect:

We can use js to process the page (similar to the following)

Function _ layout_init (){
// Modify layout of ads in news create/Edit page
If ($ ("# div-ID"). length> 0 ){
$ ("# Div-ID Div. Items Div. View: eq (4)" example .css ("margin-Right", "0 ");
$ ("# Div-ID Div. Items Div. View: eq (9)" ).css ("margin-Right", "0 ");
}
}

Then you can call it on the specific display page (usually in layout, as shown below:

$ (Document). Ready (function (){
$ ("# Content"). ajaxstop (function (){
_ Layout_init ();
});
});

Of course, here is just a simple introduction of a solution, the extra improvement is still necessary, O (∩ _ ∩) O ~

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.