Get rows by PK in CGridView

Hi all,

i am using the CGridView-widget for displaying some data.

I made it multiselectable and on pressing a button I am gettin all selected rows’ data-primary-key by


How do i get the rows now by this data-primary-key?

Explaination on why i need this:

I’d like to do something for each row with ajax-requests and if it succeeds remove the row by JS or mark it with red background if it fails.

Any hints on his?

Best regards

Try this:

I don’t want to get the dataobjects. I’d like to get the rows in Javascript to manipulate them.

Perhaps I didn’t explained it understandable.

So I try once again:

I collect the selected rows PK by



Now I’d like to do something like




Is this possible?

Try setting a class for each row with CGridView.rowCssClass e.g class_1, class_2, class_3 where the number should match with your PK’s of the rows.

Then you could access each row with javascript like

var row = $("#myyiigridview .class_[PK]");


Also look at topic Row id in CGridView…

Hope it helps you ;)


thanks a lot for your idea. I solved like following …

'rowCssClassExpression' => '($row%2?"even":"odd")." row_data_id_" . $data->id',