mjkulet
(Mjkulet)
January 22, 2011, 8:17am
1
I’ve included this code in my view page the entire row of the table clickable:
$cs->registerScript('mgrid_link','
$(document).ready(function() {
$(\'.mgrid_click tr\').click(
function() {
var href = $(this).find("a").attr("href");
if(href) {
window.location = href;
}
}
)
});'
);
It works fine at first, but after I click the header to sort or go to other page using pagination, the function is not triggered anymore.
Any ideas why? Any ideas how to fix this?
mpluss
(Mahdi Mastouri)
January 22, 2011, 9:14am
2
Hi,
Try with this method :
<?php $this->widget('zii.widgets.grid.CGridView', array(
...
'selectionChanged'=>'function(id){ /* document.location.href = "..." You can use this property : $.fn.yiiGridView.getSelection(id) */ }',
...
)); ?>
mjkulet
(Mjkulet)
January 22, 2011, 1:32pm
3
Thanks for pointing that out,mahdi.
I noticed that when I do this:
'selectionChanged'=>'function(id){ alert($.fn.yiiGridView.getSelection(id)) ;}'
it returns an ID alternately. Apparently, it only returns the value of the selected row, because clicking the row again deselects it thus returning blank id. But I think I can use this to my benefit
mdomba
(Maurizio Domba Cerin)
January 22, 2011, 8:18pm
4
That’s exactly as it says in the documentation… $.fn.yiiGridView.getSelection(id) returns the key values of the selected rows…