Hi all,
For a very specific reason / situation (using second view inside IFRAME in parent view – discussed here) I can’t use jQuery or any other JS script (that is already registered in main view), because IE gets totally wako on this.
My job, is to get ID of a record, which data is displayed in particular CGridView row as good as value in one of its columns. With jQuery it would be a piece of cake and solutions like that were discussed many times in Yii forums. But without jQuery this seems to be a hard piece. At least to me.
So, I’m looking for any solution to get object or it’s property inside some other object, without using jQuery. Is it possible in pure JS and if so, can anyone show me, how?
I’ve crafted a piece of JS code, which allows me to bind onclick event to every CGridView row. In this event I’m able to read HTML contents of each clicked row. So, I’m getting something like this:
<td style="width: 75px">2</td>
<td style="text-align: left; width: 260px"><div> Wędrowycz Jakub</div></td>
<td style="width: 150px">mężczyzna</td>
<td style="width: 150px"><div>1919-06-04</div></td>
<td style="width: 150px"><div>19060475651</div></td>
<td style="width: 75px">1</td>
My question is, how to extract value from a particular column of such row and how to get ID of the record behind each row?
For first question, the only idea I figured out, is to use JS’s string manipulation and cut off piece I’m interested in from above string. But I feel that isn’t to professional, so I would like to ask, if anyone knows a better solution?
For the second task – how to mimic, without jQuery, the behaviour of $.fn.yiiGridView.getSelection(id) function, normally used in seletionChanged property of CGridView – unfortunately I have no idea.
Thank you in advance for any tips and cheers,
Trejder