RRListView - a CListView extension to allow Ajax browser history

im using the latest version of the framework.

jQuery JavaScript Library v1.5.1

Ok guys, I’ve finally put this together as an extension.

I’ve modified it yet again so that it can be more customisable.

As far as I know it works ok, but I would obviously appreciate your feedback on it.

The extension page is here, with a detailed usage description.

@pcs2112 - please try this latest version, then come back to me if you still have problems.

@RedRabbit than you again for this extension. It had saved me a lot of time in my current project.

With pleasure - glad it helped you!

RedRabbit,

Thanks for taking the time, i’ll post feedback once i try it.

I’ve just come across a problem in the filtering, of which I haven’t had the time or inclination to find out the actual cause, but basically I noticed that a less than filter on one of my columns was being ignored, but only in my production version, not the development version.

It turns out that upgrading to JQuery 1.6.1 got rid of these problems, so I’m assuming that it is something to do with the attr and prop method bugs from JQuery 1.5.1, although as I said I haven’t searched any further.

Just in case anyone is having similar problems…

Thank you for making this extension! :D

I just plugged it into my app, which uses several custom filters in the grid (and outside of it too), and it just worked. :lol:

I am really grateful as it saved me a lot of work - I didn’t expect it to work as well as it did.

Tons of Kudos from me.

This has to be the most useful extension overall.

I am using it at http://tracker.ogitor.org/projects/bugitor/issues

You’ve got me blushing there :P

Seriously, I’m glad it came in helpful, and I’m glad to see it being used in a serious application - do let me know if anything doesn’t work as expected, and whether you think my philosophy with regards to merging query parameters and hash parameters rather than having separate widget states is the right or wrong way…

I am having the same issue. No errors… just appends the #

Ok, just as a preliminary check - are you actually using the extension version, or the version from this post?

The version to use is the one at Extension.

yes i am using the extension version

Ok, so please include the code you use for the GridView, as well as any custom model or controller code (that differs from the gii generated code), for example if you are using some kind of custom attributes in the gridview.

Hi, first thanks for this extension but i noticed that it doesn’t work when the urlManager urlFormat property set to “path”

Hello.

Glad it helped. However, I only ever use the path urlFormat and don’t have any problems.

I think your problem must come from something else.

Feel free to post some error messages and code about it.

hi, thank you for the excellent extension.

i just want to notify you that there is a conflict with facebook comments plugin.

i created an image gallery for a client and used your extension to navigate images with ajax.

if there are comments in the same page as the extension, facebook will add some GET param and invoke a js call which will add a hash to the url removing your hash, and the extension will navigate to the first page when the hash is changed to facebook’s hash.

trying to navigate to other pages using the extension will not work, because facebook takes control over the hash and changes it back.

an example you can see:

the page working fine:

sahar-rouhana.com/albums/images/158?ajax=enable&fb=10321&imp=5#Images_page=5

the link from facebook will generate the problem:

sahar-rouhana.com/albums/images/158?ajax=enable&fb=10321&imp=5&fb_comment_id=fbc_10150342218458300_19989195_10150345895478300#Images_page=5

any ideas will be appreciated.

Thanks.

I’ll try and have a look at it when I get the time (I’m quite busy at the moment).

I haven’t used the Facebook plugin, but as far as I remember, my extension should play nicely with anything else that uses the hash (as long as the parameter names don’t conflict) - I don’t think I ever replace or remove the hash, and when a hash change is detected it will only trigger an ajax action if it involves one of the registered parameters, so without having looked into it, I would guess that it is the Facebook plugin which is overriding the hash, in which case that is what would need to be corrected.

The other scenario is that the Facebook plugin uses CListView or CGridView in which case there might be a problem because my extension overrides the Javascript for those widgets, in which case I would perhaps have to see about completely separating it from them.

Hi, I don’t know what I do wrong, but as I use RRViews, the Filter-Methods don’t work anymore…

Here is my code:




<?php 


$this->widget('ext.RRViews.RRGridView', array(

	'id'=>'customer-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

        //'ajaxUpdate'=>true,

        //'ajaxUrl'=>CHtml::normalizeUrl(Yii::app()->createUrl('/customer/customeradminplain')),

        'cssFile' => Yii::app()->baseUrl . '/css/gridview/styles.css',

        //'afterAjaxUpdate' => 'function(id,data){ alert(id) }',

        //'selectionChanged'=>'jumpToUpdate',

        'selectableRows'=>2,

        'columns'=>array(

                array(

                    'class'=>'CCheckBoxColumn',

                    'value'=>'$data->customer_id',

                    'id'=>'customer_id',

                ),

		array(

			'class'=>'CButtonColumn',

                        'template'=>'{update}',

                        'header'=>'edit',

                        'updateButtonUrl'=>'Yii::app()->createUrl("/customer/update", array("id" => $data->customer_id))',

		),

                array(

                    'name'=>'cus_name',

                    'type'=>'raw',

                    'value' => '$data->cus_name .", ". $data->cus_prename',

//                    'htmlOptions'=>array(

//                       'style'=>'width:230px',

//                     ),      

                ),

                /*array(

                    'name'=>'status',

                    'value'=>'CHtml::encode($data->status)',

                    'filter'=> SWHelper::allStatuslistData($model),

                ),*/

                //'customer_id',

		//'parent_customer_id',

		//'cus_number',		

//		array(

//                    'name'=>'cus_prename',

//                    'htmlOptions'=>array(

//                       'style'=>'width:230px',

//                     ),

//                ),

                array (

                    'name'  => 'addresses_add_street',

                    'type'  => 'raw',

                    'value' => 'CHtml::Link($data->addresses[0]->add_street.CHtml::image(Yii::app()->request->baseUrl."/images/edit.png"),

                                        "",

                                        array(                                             

                                             "onClick" => CHtml::ajax(

                                                array(

                                                    "type"   => "POST",

                                                    "url"    => "js:$(this).attr(\'href\')",

                                                    "update" => "#divForForm",

                                                    "success"=>"js:function(){

                                                                addAddress._updateAddress_url = \'".Yii::app()->createUrl("/address/update",array("id"=>$data->addresses[0]->address_id))."\';

                                                                addAddress();

                                                                $(\"#dialogAddress\").dialog(\"open\");

                                                                }",

                                                     )

                                             ),                                             

                                             "style"=>"text-decoration:none; cursor:pointer",

                                        )

                               )',

                    'htmlOptions'=>array(

                       'style'=>'width:170px',

                     ),

                ),

                array (

                    'name'  => 'addresses_add_town', 

                    'value' => '$data->addresses[0]->add_town',

                    'htmlOptions'=>array(

                       'style'=>'width:100px',

                    ),

                ),

                array (

                    'name'  => 'communications.com_value',

                    'type'  => 'raw',

                    'value' => 'CHtml::Link($data->communications[0]->com_value.CHtml::image(Yii::app()->request->baseUrl."/images/edit.png"),

                                        "",

                                        array(                                             

                                             "onClick" => CHtml::ajax(

                                                array(

                                                    "type"   => "POST",

                                                    "url"    => "js:$(this).attr(\'href\')",

                                                    "update" => "#divForForm",

                                                    "success"=>"js:function(){

                                                                addCommunication._updateCommunication_url = \'".Yii::app()->createUrl("/communication/update",array("id"=>$data->communications[0]->communication_id))."\';

                                                                addCommunication();

                                                                $(\"#dialogCommunication\").dialog(\"open\");

                                                                }",

                                                     )

                                             ),                                             

                                             "style"=>"text-decoration:none; cursor:pointer",

                                        )

                               )',

                    /*'htmlOptions'=>array(

                       'style'=>'width:100px',

                     ),*/

                ),

                'cus_newsletter',

                array(

			'class'=>'EButtonColumnWithClearFilters',

                        'template'=>'{delete}',

                        'deleteButtonUrl'=>'Yii::app()->createUrl("/customer/delete", array("id" => $data->customer_id))',

                ),		

	)

)); 


$this->endWidget();


?>



And I use this code inside the model:




public function search()

	{

		// Warning: Please modify the following code to remove attributes that

		// should not be searched.


		$criteria=new CDbCriteria;

                

                $criteria->with=array('addresses'=>array('together'=>true),'communications'=>array('scopes'=>'mainphone'));


		$criteria->compare('customer_id',$this->customer_id);

		$criteria->compare('parent_customer_id',$this->parent_customer_id);

		$criteria->compare('vdsite_id',$this->vdsite_id);

		$criteria->compare('paymenttype_id',$this->paymenttype_id);

		$criteria->compare('user_id',$this->user_id);

		$criteria->compare('cus_number',$this->cus_number,true);

		$criteria->compare('LOWER(cus_name)',strtolower($this->cus_name),true);

		$criteria->compare('LOWER(cus_prename)',strtolower($this->cus_prename),true);

		$criteria->compare('cus_birthdate',$this->cus_birthdate,true);

		$criteria->compare('cus_gender',$this->cus_gender);

		$criteria->compare('cus_creationdate',$this->cus_creationdate,true);

		$criteria->compare('cus_deleted',0);

		$criteria->compare('status',$this->status,true);

		$criteria->compare('cus_uid',$this->cus_uid,true);

		$criteria->compare('cus_company_type',$this->cus_company_type);

		$criteria->compare('cus_company_number',$this->cus_company_number,true);

		$criteria->compare('cus_securitycheck',$this->cus_securitycheck);

		$criteria->compare('cus_barcode',$this->cus_barcode,true);

                $criteria->compare('cus_invoice',$this->cus_invoice,true);

                

                $criteria->compare('cus_newsletter',$this->cus_newsletter,true);

                

                $criteria->compare('addresses.add_town',$this->addresses_add_town,true);

                $criteria->compare('addresses.add_street',$this->addresses_add_street,true);

		

                

		return new CActiveDataProvider(get_class($this), array(

			'criteria'=>$criteria,

                        'sort'=>array(

                            'defaultOrder'=>'cus_name ASC',

                        ),

                        'pagination'=>array(

                            'pageSize'=>50,

                        ),

		));

	}



And don’t forget the controller:




public function actionCustomerAdmin()

	{

		$model=new Customer('search');


		$model->unsetAttributes();  // clear any default values

		if(isset($_GET['Customer']))

			$model->attributes=$_GET['Customer'];


                $this->render('_customer_admin',array(

                        'model'=>$model,

                ));

	}



Thank you for your help! Cheers Phil

I’m using the latest yii - version from google svn…

Hi,

I have a serious problem with rrviews, after upgrading to yii 1.9 ->looks like some of the js api has changed, so some of your code isn’t working any more:(

I’m sorry to say, but my js-skills aren’t good enough to fix it…

Regards Philipp

You need to delete all in your assets directory whenever you upgrade. :)

Try that first

Did that before… Doesn’t help… I have a ListView on the same page… could that be an issue…?