我正在使用Yii1和X-editable。我将数据提供给源。但是,当数组为空时,会给我错误“加载列表时出错”。 我将如何向Select这样的数组中添加空选项。
In Image when source is blank it gives error and I want to put and empty option to the select.
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'fees-master-grid',
'htmlOptions'=>array('class'=>'adv-table'),
'itemsCssClass'=>'display table table-bordered table-striped dataTable',
'pagerCssClass'=>'dataTables_paginate paging_bootstrap pagination',
'dataProvider' => $model->search(),
'columns'=>array(
array
(
'class' => 'application.extensions.editable.EditableColumn',
'name' => 'fees',
'headerHtmlOptions' => array('style' => 'text-align:left;'),
'editable' => array(//editable section
'type' => 'select',
'source' => CHtml::listData(CodeMaster::model()->findAll(array('order' => 'code ASC')), 'code_id', 'code'),
'url' => $this->createUrl('/code/update', array('model'=>'CodeMaster', 'field'=>'fees')),
'onShown' => 'js: function(event) {
var tip = $(this).data("editableContainer").tip();
tip.find("input").focus();
}',
'success' => 'js: function(response, newValue) {
if(!response.success) return response.msg;
}',
'options' => array(
'ajaxOptions' => array('dataType' => 'json'),
)
)
),
)));