javascript - 在easyui可编辑数据网格中动态添加选择框选项
问题描述
我正在使用 easyui 可编辑数据网格,我必须在其中显示带有一些选项的选择下拉列表。我在下面尝试过:
<table id="bulkchannel_edit" style="width:100%; height:500px;"></table>
javascript:
var parentCategories = {};
$(document).ready(function(){
$.ajax({
url: "<?php echo base_url() ?>index.php/Channels/getParentChildChannelCategories",
dataType: 'json',
success: function(response){
console.log('response',response);
console.log('parent_categories',response.parent_categories);
parentCategories = response.parent_categories;
// childCategories = response.child_categories;
}
});
});
$(function(){
$('#bulkchannel_edit').datagrid({
title:'Editable DataGrid',
iconCls:'icon-edit',
singleSelect:true,
idField:'itemid',
url:'<?php echo base_url() ?>index.php/Channels/get_test_json_data',
columns:[[
{field:'channel_name',title:'Channel Name',editor:"textbox"},
{field:'category_name',title:'Category',width:100,
editor:{
type:'combobox',
options:{
valueField:'channel_category_id',
textField:'category_name',
data:parentCategories,
required:true
}
}
}
]]
});
});
在上面的代码中,我想为“category_name”加载一个选择下拉选项,在其中我从 ajax 调用“Channels/getParentChildChannelCategories”动态获取 json 数据,如下所示:
显示为空下拉列表,没有其他选项,只有一个主值,必须与选择框中的所有选项一起显示为选定选项。如下图所示:
任何帮助,谢谢。
解决方案
推荐阅读
- angular - Angular 搜索框无法按预期工作
- html - 请参阅选择下拉列表中的以下片段单击您可以看到带有滚动条的选项,我想更改滚动条样式
- c++ - 函数参数延续
- javascript - “X”类型的参数不能分配给“Y”类型的参数
- amazon-web-services - 如何下载公共 AWS S3 存储桶?
- angular - ngIf 语句在 Ionic 4 中多次执行
- c# - 如果先提取任务,则异步任务死锁
- python - zipline:target_order 未在 handle_data 中执行
- python - 转换为熊猫数据框时如何删除csv中的自动索引
- ios - SWIFTUI:- 有没有办法在滚动滚动视图时关闭弹跳?