How to enable or disable editable option using x-editable in yii cgridview?

My cgridview

               'name'=>'teamLeader_id', 
                'class' => 'bootstrap.widgets.TbEditableColumn',
                'headerHtmlOptions' => array('style' => 'width:180px'),
                'editable' => array(
                    'type' => 'select',
                    'url' => Yii::app()->createUrl("employee/assignToTeamLeader"),
                    'source' => $usersList,
                    'enabled' =>'$data->employeType == 1 ? false : true',
                    'success' => 'js: function(response) {
                        if(response.success == false){ 
                            console.log(response.message);
                            return response.message;
                        }
                    }',
                    'options' => array(
                    'ajaxOptions' => array('dataType' => 'json')
                    ),
                )

My problem is that when I check the condition in the included parameter, it does not work at all. I do not know why? Any help would be appreciated. Thanks.

+4
source share
1 answer

x-editable seems to only have an attribute disable, so just use this :)

http://x-editable.demopage.ru/index.php?r=site/widgets#Options

            'name'=>'teamLeader_id', 
            'class' => 'bootstrap.widgets.TbEditableColumn',
            'headerHtmlOptions' => array('style' => 'width:180px'),
            'editable' => array(
                'type' => 'select',
                'url' => Yii::app()->createUrl("employee/assignToTeamLeader"),
                'source' => $usersList,
                'disabled' =>'$data->employeType == 1 ? true : false',
                'success' => 'js: function(response) {
                    if(response.success == false){ 
                        console.log(response.message);
                        return response.message;
                    }
                }',
                'options' => array(
                'ajaxOptions' => array('dataType' => 'json')
                ),
            )
+1
source

Source: https://habr.com/ru/post/1605907/


All Articles