
使用下面的代码我获取所有“名称”列值
$.fn.yiiGridView.getColumn("CGridViewUser",1).text();
Run Code Online (Sandbox Code Playgroud)
如果我想获取选定行的“名称”列值(如图所示),如何实现?
首先向您的 GridView 添加一个 ID。
<?php
$this->widget('zii.widgets.grid.CGridView', array
(
'dataProvider'=>$dataProvider,
'htmlOptions'=>array('id'=>'MyID'), //MyID is an ID to grid wrapper
........
........
Run Code Online (Sandbox Code Playgroud)
现在,jQuery
$("#MyID table tbody tr").click(function()
{
$this=$(this);
var firstColVal= $this.find('td:first-child').text();
var secondColVal= $this.find('td:nth-child(2)').text();
var lastColVal= $this.find('td:last-child').text();
alert(firstColVal);
});
Run Code Online (Sandbox Code Playgroud)
它会起作用的。
| 归档时间: |
|
| 查看次数: |
4213 次 |
| 最近记录: |