$.fn.yiiGridView.getSelection issue

CGridView view with custom template

$this->widget(‘application.components.CGridView’, array(

‘id’=>‘notesgrid’,

‘selectableRows’=>1,

‘template=>’<div class=“grid-view-body”>{items}</div><div>{pager}</div>’,

When i try to access the selected row I get nothing. However, I debug this issue and found out that following jquery line of getSelection method in jquery.yiigridview.js file does not work with the above template.


this.children(’.’ + settings.tableClass).children(‘tbody’).children().each(function (i) {


Previous version had following jquery code which worked with custom template.


$(’#’+this.attr(‘id’)+’ .’+settings.tableClass+’ > tbody > tr’).each(function(i){


Anyone got a solution for this?

Hi Don123,

I think you should report this issue in github.

[EDIT]

As for the moment what we can do may be, as you may agree …

  1. Remove the wrapping <div> from your template … you may wrap the whole grid, not only the grid’s {item} … and modify your css selector accordingly.

  2. Add extra lines to retrieve selected id on your own in your selectionChanged function … discarding the given ‘id’ parameter.

or

  1. Customize jquery.yiigridview.js … you may not like it.

GitHub issue - https://github.com/yiisoft/yii/issues/769

Thank you. I will try this.