CGriView Row Selection

Hi,

I need to highlight selected row manually.

Which mean not using ‘selectableRows’=>1 settings in CGridView.

How to apply style for selected CGridView <tr>?

Thank you

CGridView… .to show a row as selected adds/removes the class "selected" to a row…

How to access selected row?


($(this).parent().parent())

or what?

Dear mdomba,

I found the way to highlight the row using below code snippet:


$(this).parent().parent().addClass('selected')

But how to remove the previously selected row highlighting (CSS class - selected)?

Thank you

Dear mdomba,

I have found the way to do this using jQuery:




$('tr.selected').removeClass('selected');

$(this).parent().parent().addClass('selected');



Anyway thank you for your effort.

Hi

I also faced with need to select row via script.

I think it’s not enough to simply set class of selected row. CGridView also stores checked rows in array:


$rows.addClass('selected');

$checks.prop('checked', true);

$checksAll.prop('checked', true);

It would be good to add setSelection methos to YiiGridView.

Hi all

I’ve researched issue and created extension that allows to select rows by GET param

and remembers selected rows on sorting / paging

Link to extension: SelGridView

Feel free to comment.