How To Update Cgridview With Javascript

Hi All,

I got the problem about the cgridview is not reload when call method $.fn.yiiGridView.update(‘list_product’);

Please help!

Below is the javascript and cgridview page…

<button class="btn" type="button" id="btn_product" value="Product">Product</button>



				'type'=>'striped bordered condensed',


				'dataProvider' => $dataProvider,		




						'class' => 'CCheckBoxColumn',


						'selectableRows' => '2',




						'name'=> '', 










	//prevent normal action of tag


	// Get selected items from cgridview - checkbox 

	checked_item_list = $('input[name=\"p_col_chkbox[]\"]:checked');


	var list_p_ids = new Array();

	for(i = 0; i < checked_item_list.length; i++)


		list_p_ids[i] = checked_item_list[i].value;	



	// Call ajax

	var request = $.ajax({		

		url: "<?= Yii::app()->controller->createUrl('updateProduct') ?>",		

		type: "POST",

		data: {theChkIds:list_p_ids}, 

		dataType: "text",

		success:function(data) {			

			// Update gridview



	    error:function(data) {	    






check with firebug in firefox… see what happns in the console.

Hi Rajith,

it’s throw message: –

[14:31:01.785] TypeError: $.fn.yiiGridView is undefined @ http://localhost/spmt/assets/6892f04b/jquery.js:646



ok… so its jquery problem .

is it u registered it in layouts/main, or any repeat registration ?


normal gridview has $.fn.yiiGridView, i dnt knw about TbGridView . check it out.

comment unwanted jquery’s… then try…

I don’t register any Jquery in layout/main.

TbGridView is one of widget of Yii-boostrap. So I think $.fn.yiiGridView also works too.

$(function() {



use this

in action.

<?php if (Yii::app()->request->isAjaxRequest){

Yii::app()->clientscript->scriptMap['jquery.js'] = false;

Yii::app()->clientscript->scriptMap['jquery-ui.min.js'] = false;

Yii::app()->clientscript->scriptMap['jquery.yiigridview.js'] = false;


Hi Rajith,

It still doesn’t work, on the console till throw '$.fn.yiiGridView is undefined".

I’ve changed another way to reload the cgridview by replace it with CJSON data like this:


The getData.content is the cgridiew data

Thank you very much for your help.