Update Pages On Cgridview

Hi,

I have this code …




$.fn.yiiGridView.update('user-grid',{ data:{page_size: $(this).val() }})



It was copied from the another topic, everything else is setup correctly as well etc.

I am getting this JS error, which appears to be related to the update function, can anyone help me?




TypeError: settings is undefined

[Break On This Error] 	


$grid.addClass(settings.loadingClass);



Any ideas anyone?

No have any answers?

According to all the tutorials it should work, but I think it was an old version of Yii.

Dear Friend

There are sometimes we have to update the gridView based on form fields placed outside the grid.

I have done it by updating the grid by single value.

These are couple of examples.

1.I have 2 tables. [b]Brand/b and [b]Item/b.

Through b_id, a brand has MANY items.

Through external dropDrownList,I am updating the grid.


$('#subForm form').submit(function(){

        $.fn.yiiGridView.update('item-grid', {

        data:{'Item[b_id]':$('#subForm #Item_b_id').val()}

        });

        return false;

        

});

");






In this example, I have three tables:user,customer,UserCustomer.

user has MANY_MANY relation through userCustomer.

I am getting ids from usergrid and customergrid by getChecked method.

I creating UserCustomer from these values by AJAX. After successful creation,

I am updating the userCustomer grid for the particular user.




Yii::app()->clientScript->registerScript('assignCustomer','

$("body").on("click","#butt",function(){

        $.ajax({

                type:"POST",

                url:"'.Yii::app()->createUrl('userCustomer/create').'",

                data:$(".wide form").serialize(),

                success:function(data){

                $("#user-customer-grid").yiiGridView("update",{

                        data:{"UserCustomer[user_id]":$("#user").val()}});

                }

                

                });

        return false;

        });




');




Note: In first example $(this)means whole form.

  In second example $(this) means [b]click[/b] button.

To avoid that confusion, I am fetching the values by their ids.

Regards.

Hi,

Thanks for your help so far. I have this code, can anyone see why its not working …




<?php


	$this->widget("zii.widgets.grid.CGridView", array(

		"id" => "message-broadcast-grid",

	   	"dataProvider" => $data->data_providers->broadcast_data_pending,

		"columns" => array(

			array(

				"name" => "subject",

				"header" => "Subject"

			),

			array(

				"headerHtmlOptions" => array("class" => "header-col"),

				"class" => "CDataColumn",

				"header" => "List",

				"value" => 'MessageBroadcast::model()->findByPK($data->id)->broadcast_to_services[0]->list_to_companyservice->list->name',

			),

			array(

				"name" => "DateTime",

				"header" => "Send Date & Time"

			),

			array(

				"class" => "bootstrap.widgets.TbButtonColumn",

				"template" => "{update} {delete}",

				"htmlOptions" => array("style" => "width: 75px"),

				"updateButtonUrl" => 'CHtml::normalizeUrl(array("messagebroadcast/edit", "id" => $data->id))',

			),

		),

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

		"summaryText" => "Viewing page {page} of {pages} pages out of {count} broadcasts"

	));

		

?>


<script>


	$(document).ready(function() {

		

		alert("Hello");


		$.fn.yiiGridView.update("message-broadcast-grid", {

			

			data: {

				

				pageSize: 10

				

			}

		

		});

	

	});


</script>