Yii Framework Forum: Update Pages On Cgridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Update Pages On Cgridview Rate Topic: -----

#1 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 428
  • Joined: 18-November 10
  • Location:UK

Posted 26 November 2012 - 05:58 PM

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);

0

#2 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 428
  • Joined: 18-November 10
  • Location:UK

Posted 27 November 2012 - 08:24 AM

Any ideas anyone?
0

#3 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 428
  • Joined: 18-November 10
  • Location:UK

Posted 29 November 2012 - 12:53 PM

No have any answers?

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

#4 User is offline   seenivasan 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 620
  • Joined: 17-June 12
  • Location:Chennai,TamilNadu,India.

Posted 02 December 2012 - 04:53 AM

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. Brand(id,name) and Item(id,name,b_id).
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.
2.
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 click button.

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

Regards.
0

#5 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 428
  • Joined: 18-November 10
  • Location:UK

Posted 03 December 2012 - 09:11 AM

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>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users