Cgridview - Problem With $.fn.yiigridview.getselection(Id)

I have a CGridView. Using the option selectionChanged when I click on the row I load another CGridView. For the first time the function/selector $.fn.yiiGridView.getSelection(id) gives correct selected ID and I successfully load the second CGridView. But when I click the second row of the first CGridView function/selector $.fn.yiiGridView.getSelection(id) does not work and in a console/debug gives an error “Uncaught TypeError: Cannot read property ‘tableClass’ of undefined”. What could be the problem.

This the that code snippet:


'selectionChanged'=>"js:function(id){

   $('#ports').empty();

   var url = '".Yii::app()->urlManager->createUrl('site/showports', array('id'=>''))."'+ $.fn.yiiGridView.getSelection(id);

   $('#ports').load(url);

}",

Hi

When you click on a gridview row, then the row is selected and $.fn.yiiGridView.getSelection(id) can find the id.

When you click on that same row again, the row is de-selected and $.fn.yiiGridView.getSelection(id) cannot find the id.

Use a custom CGridView button, OR if you want to click anywhere on the row, then use jquery to get the id.

Check this Dynamic Parent Child CGridViews, specifically the 3 ajax methods.

Hello Gerhard,

Thanks for the reply.

Today I will try to follow the article behind that link.

But the interesting thing in my situation is the error:


"Uncaught TypeError: Cannot read property 'tableClass' of undefined".

I understand that after second clicking (select->un-selecting) the row there should be no "selected id". But before loading the second CGridView without selecting any row in the first CGridView in a console/debug if I give a command like


"$.fn.yiiGridView.getSelection('device-grid');"

I get at list an empty result but not an error like above. After selecting any row in the first CGridView I get at least some "ID" and deselecting that row I get again an empty result but again not an error. Just after loading the second CGridView the command in the console/debug


"$.fn.yiiGridView.getSelection('device-grid');"

gives an error. In the same time if I give this command regarding the second CGridView like


"$.fn.yiiGridView.getSelection('port-grid');"

the command is successful.