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


$.fn.yiiGridView.getSelection(target_id)

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:

http://www.yiiframework.com/doc/api/1.1/CActiveRecord#findAllByPk-detail

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


$.fn.yiiGridView.getSelection(target_id)

.

Now I’d like to do something like


$("myyiigridview").row(PK).hide()

or


$("myyiigridview").row(PK).changeBackground()

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]");

row.css("background-color","red");



Also look at topic Row id in CGridView…

Hope it helps you ;)

Hey,

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


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