Ajax pagination not works in CarrayDataProvider and CListView.

Dear all,

I am using CarrayDataProvider and CListView to display datas now. But I found the ajax pagination is not working when I add


    'keyField'=>'questions_id',



.

Here is one of my dataproviders …I have same codes for another data provider, this one is only different with


    'keyField'=>'questions_id',



.

And AJAX is not woking anymore… Thanks so much! :D

in my View:


$this->widget('zii.widgets.CListView', array(

             'dataProvider'=>$questionsDataProvider,

             'itemView'=>'_questionsview',

             'pagerCssClass'=>'right',

             'template'=>'{items}{pager}',

              'ajaxUpdate'=>true,

));

In my Controller:


    $questions=QuestionsEmail::model()->findAllByAttributes(array('user_id'=>$user->id));

     $questionsDataProvider=new CArrayDataProvider($questions,array(

    'pagination'=>array(

        'pageSize'=>5,

    ),

    'keyField'=>'questions_id',

));

Everything should be fine…but AJAX is not working… No ajax request submitted…when you click on the pager, a new url address will be generated…

No errors in firebugs…also

Thanks!!!

try using firebug, with firebug you can see where is the error.

Thanks for your help. But firebug does not give me any errors at all…

It’s so weird…I use same codes in the other page…it works…Anyone encounters same problems?

same here,

EDIT:

i’m using Xubuntu 11.10 with Google Chrome 18.0.1025.168 (Developer Build 134367 Linux) Ubuntu 11.10 and when i switch to Moz FF 13.0.1 it’s works normally.

Okay i found it, this is definitely the "problem" https://github.com/yiisoft/yii/commit/89be0cb01c2911ee8a2e750af8c3425f917c9124#framework/zii/widgets/assets/gridview/jquery.yiigridview.js

yiiGridView won’t recognized pager link.

ummm…I think I’m using the CListView instead of gridVIew…

Also, I’m kinda curious about this fix…What should I do exactly? Doing so like #964 and #803 will ignore any other link which doesn’t have “sort-link” class.

Thanks~ :D

i think @resurtm have good approach with his ‘sort-link’ class, so i just made this patch https://github.com/yiisoft/yii/pull/972/files to keep his ‘sort-link’ class working and make pager link work again. or you can revert back manually for awhile

sorry for my bad english.

Hey my friend, sorry for the late reply but this still not works for me.

I think i am not using the grid view, instead, i simply create _view file and use CarrayDataProvider and [size="4"][font="Arial Black"]CListView[/font][/size].

Any ideas about that…? it’s so weird… sample codes are here:

_view.php


<?php

$truncated = (strlen($data->name) > 20) ? substr($data->name, 0, 20) . '...' : $data->name;

$link="<h4><a href='http://www.mysite.com/sell/".$data->id."'>".CHtml::encode($truncated)."</a></h4>";

?>

<tr>

<th>

<?php echo $link; ?>

</th>

<td>

<?php echo $data->university->name; ?>

</td>

<td>

<?php echo $data->create_time; ?>

</td>

</tr>

For dataproviders and clistview:


<div><h2>My MarketPlace Posts</h2>

<table>

<?php 

if ($sell){

$this->widget('zii.widgets.CListView', array(

             'dataProvider'=>$sellDataProvider,

             'itemView'=>'_sellview',

             'pagerCssClass'=>'right',

             'template'=>'{items}{pager}{summary}',

));

}else{

echo "You have not posted any Sell/Buy in MarketPlace yet.";

}

?>

</table></div>



Hey my friend, sorry for the late reply but this still not works for me.

I think i am not using the grid view, instead, i simply create _view file and use CarrayDataProvider and [size="4"][font="Arial Black"]CListView[/font][/size].

Any ideas about that…? it’s so weird… sample codes are here:

_view.php


<?php

$truncated = (strlen($data->name) > 20) ? substr($data->name, 0, 20) . '...' : $data->name;

$link="<h4><a href='http://www.mysite.com/sell/".$data->id."'>".CHtml::encode($truncated)."</a></h4>";

?>

<tr>

<th>

<?php echo $link; ?>

</th>

<td>

<?php echo $data->name; ?>

</td>

<td>

<?php echo $data->create_time; ?>

</td>

</tr>

For dataproviders and clistview:


<div><h2>My MarketPlace Posts</h2>

<table>

<?php 

if ($sell){

$this->widget('zii.widgets.CListView', array(

             'dataProvider'=>$sellDataProvider,

             'itemView'=>'_sellview',

             'pagerCssClass'=>'right',

             'template'=>'{items}{pager}{summary}',

));

}else{

echo "You have not posted any Sell/Buy in MarketPlace yet.";

}

?>

</table></div>



anyone who has encountered this?.. ;D ;D ;D