Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Dataprovider Pagesize Problem With Related Models

$
0
0
Hi guys.

In my model's search() function, I retrieve parent records and their related child records via "with" statements; and I also use "together = true".

I display these records in a CListView. The CListView's HTML looks like this (simplified):
<tr>
	<td>	<b>Parent Record Label</b>	</td>
	<td>	<p>Parent Record Data</p>	</td>
</tr>

<tr>
	<td>	<b>Child Record Heading</b> </td>
	<td>	<u>Label Column1</u> </td>
	<td>	<u>Label Column2</u> </td>
</tr>
		
<tr>
	<td>				
	</td>
	<td>
		<?php foreach ($data->relation_to_child_model as $child):?>
			<?php echo $child->data1; ?>	</br>
		<?php endforeach; ?>	
	</td>
	<td>
		<?php foreach ($data->relation_to_child_model as $child):?>
			<?php echo $child->data2; ?>	</br>
		<?php endforeach; ?>	
	</td>
</tr>

The result looks something like this:

Parent Record Label: _____ Parent Record Data
Child Record Heading: ____ Label Column1 ___ Label Column2
___________________________Child Data1 ______ Child Data2
___________________________Child Data1 ______ Child Data2

Parent Record Label: _____ Parent Record Data
Child Record Heading: ____ Label Column1 ___ Label Column2
___________________________Child Data1 ______ Child Data2
___________________________Child Data1 ______ Child Data2
___________________________Child Data1 ______ Child Data2
___________________________Child Data1 ______ Child Data2
___________________________Child Data1 ______ Child Data2



My problem is this:
Let's say the PageSize = 10 (in dataprovider generation in search() function).

If the data consists of 15 parent records, then CListView will display 10 records with a pager to allow the user to page to the remaining parent records - nothing wrong so far.

However, if the data consists of a parent record with 15 related child records, then CListView still only displays 10 of these records, but WITHOUT showing a pager to allow the user to page to the remaining child records.

Any ideas?

Many thanx.

Viewing all articles
Browse latest Browse all 18717

Trending Articles