0
我想表明我在彈出的數據,一旦用戶選擇處顯示的是與使用Ajax用戶所選部門的Yii的RenderPartial Eselect2設計它不能正常工作
工作人員的名字,Geeting
數據的正確,但我的表現工作人員在Yii中Eselect2的Widget
多個選項名稱,即Eselect2設計不來它顯示正常
選擇下拉用戶使用CTRL鍵選擇多個選擇。
我的Codings,在該科工作人員我顯示eselect2小部件數據的。
阿賈克斯編碼
<div id ="staffs></div>
function selectstaff(id)
{
$.ajax({
type: 'POST',
url: '<?php echo Yii::app()->createAbsoluteUrl("user/users/ajaxselectstaff"); ?>',
data: 'id=' + id,
success: function (packages) {
$('#staffs').html(packages);
}
});
}
控制器編碼
public function actionAjaxselectstaff() {
$id = Yii::app()->request->getPost('id');
$model = Users::model()->getAllStaffDepartment($id);
$this->renderPartial('ajaxselect', array('model' => $model));
}
模型編碼,
public function getAllStaffDepartment($id, $type = '') {
$model = UserAccount::model()->findAll('department_code=:id', array(':id' => $id));
$userid = "";
$result = "";
if (isset($model)) {
foreach ($model as $data) {
$userid .= $data->user_id . ",";
}
}
$userid = trim($userid, ',');
if ($userid != "") {
$criteria = new CDbCriteria();
$criteria->condition = "user_role_id!=" . Yii::app()->mconstant->CONST_FIVE . " AND user_role_id!= " . Yii::app()->mconstant->CONST_SIX . " AND user_role_id!= " . Yii::app()->mconstant->CONST_NINE . " AND user_id IN (" . $userid . ")";
$result = Users::model()->findAll($criteria);
$data = CHtml::listData($result, 'user_id', 'real_name');
return $data;
} else {
return false;
}
}
Ajaxselect頁:
<?php
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
Yii::app()->clientScript->scriptMap['jquery.min.js'] = false;
if ($model) {
?>
<?php
$this->widget('ext.select2.ESelect2', array(
'name' => 'users',
'id' => 'users',
'data' => $model,
'htmlOptions' => array(
'multiple' => true,
'placeholder' => 'Select Users',
),
));
?>
<?php
} else {
echo "No Staff's Found";
}
?>
我的代碼有什麼問題? Am改變頁面渲染eselect2小部件設計得到正確,但渲染部分eselect2設計沒有得到,