Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Yii 将ID传递给CGridView_Yii - Fatal编程技术网

Yii 将ID传递给CGridView

Yii 将ID传递给CGridView,yii,Yii,如何将网格行id从CGridView传递到在对话框中打开的另一个CGridView中的筛选值 表单网格的我的视图代码(参见屏幕截图) 显然,您可以使用AJAX获取弹出窗口,因此我首先要确保编辑按钮的ID与您要打开的项目的ID相同。然后可以执行以下JS(使用JQUERY) 您还可以将id添加为数据,以便使用$\u POST获取它,而不是将其作为函数定义的变量。如果在php文档中编写JS,您可以使用$this->createUrl,但这正是您喜欢的 如果您无法解决您的问题,那么让我们看看您现在是如

如何将网格行id从CGridView传递到在对话框中打开的另一个CGridView中的筛选值

表单网格的我的视图代码(参见屏幕截图)


显然,您可以使用AJAX获取弹出窗口,因此我首先要确保编辑按钮的ID与您要打开的项目的ID相同。然后可以执行以下JS(使用JQUERY)

您还可以将id添加为数据,以便使用
$\u POST
获取它,而不是将其作为函数定义的变量。如果在php文档中编写JS,您可以使用
$this->createUrl
,但这正是您喜欢的


如果您无法解决您的问题,那么让我们看看您现在是如何实施的。

我不确定。。。但我有一个技巧去做。。。。 如果我不得不做这样的事

我会给类的htmlOptions,然后我会得到一个值,应该是一个id打开弹出

示例

  <?php $this->widget('bootstrap.widgets.TbGridView', array(
           'dataProvider' => $dataProvider ,
           'type' => TbHtml::GRID_TYPE_BORDERED,
           'template' => "{items}",
           'columns' => array(
                array(
                    'name' => 'vendor_configuration_id',
                    'header' => $dataProvider->model->getAttributelabel('vendor_configuration_id'),
                    'htmlOptions' => array('class'=>'idClass'),

                ),
                array(
                    'name' => 'menu_type',
                    'header' => $dataProvider->model->getAttributelabel('menu_type'),
                    'htmlOptions' => array(),
                ),

?> 
//基于此id的openn弹出窗口或基于此id的caal ajax检索数据

});

请添加CGridView实现的代码。@user714965添加了CGridView实现代码。。。
$(".edit").on("click", function() {
    var id = $(this).attr("id");
    $.ajax({
        type:"POST",
        url: "controller/action/"+id;
        success: function(data) {
             //open dialog box and fill it with data
        }
});
  <?php $this->widget('bootstrap.widgets.TbGridView', array(
           'dataProvider' => $dataProvider ,
           'type' => TbHtml::GRID_TYPE_BORDERED,
           'template' => "{items}",
           'columns' => array(
                array(
                    'name' => 'vendor_configuration_id',
                    'header' => $dataProvider->model->getAttributelabel('vendor_configuration_id'),
                    'htmlOptions' => array('class'=>'idClass'),

                ),
                array(
                    'name' => 'menu_type',
                    'header' => $dataProvider->model->getAttributelabel('menu_type'),
                    'htmlOptions' => array(),
                ),

?> 
$('.idClass').on("click",function(){

var neededId = $(this).html();

 alert(neededId );     
});