如何通过双击访问Yii Cgridview中所选行的id?
试试这个:如何通过双击访问Yii Cgridview中所选行的id?,yii,Yii,试试这个: <?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'message-grid', //'selectionChanged'=>'js:function(id){location.href = "'.$this->createUrl('view').'/id/"+$.fn.yiiGridView.getSelection(id);}', 'selectionCha
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'message-grid',
//'selectionChanged'=>'js:function(id){location.href = "'.$this->createUrl('view').'/id/"+$.fn.yiiGridView.getSelection(id);}',
'selectionChanged'=>'function(id){location.href = "'.$this->createUrl('view').'&id="+$.fn.yiiGridView.getSelection(id)+"&f=s";}',
//'dataProvider'=>$model->sentitem(),
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'class'=>'CCheckBoxColumn',
'id'=>'chk',
'selectableRows'=>'2',
//'htmlOptions'=>array('width'=>'40px'),
),
下面的代码将加载项目的查看页面。 (url=>itemcontroller/view/id/+selectedId)
有错误吗?尝试在dbclick处理程序中console.logid
,它返回什么?注意,$.fn.yiiGridView.getKey
自Yii 1.1.9
起被标记为不推荐使用。
$('#message-grid tbody tr').live('dbclick', function() {
var id = $.fn.yiiGridView.getKey(
'message-grid',
$(this).prevAll().length
);
});
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'id-grid',
'dataProvider'=>$dataProvider,
'filter'=>$model,
'selectableRows'=>1,
'selectionChanged'=>'function(id){ location.href = "'.$this->createUrl('view').'/id/"+$.fn.yiiGridView.getSelection(id);}',