问题描述
我有一份包含每天时间表的经典报告。没有,每天一个或多个条目。它看起来像这样:
select
week_no,apex_item.disPLAY_AND_SAVE(p_idx => 8,p_value => plan_id) as ID,apex_item.select_list(p_idx => 1,p_list_values => 'S1;1,S2;2,S3;3',p_attributes => 'size="3" multiple="multiple"',p_show_null => 'NO',p_show_extra => 'NO',p_item_id => plan_id || '_1',p_value => monday) as monday,apex_item.select_list(p_idx => 2,p_item_id => plan_id || '_2',p_value => tuesday) as tuesday,apex_item.select_list(p_idx => 3,p_item_id => plan_id || '_3',p_value => wednesday) as wednesday
from plan;
我可以选择多个值并将它们保存到我的表中。它像这样“1,2”一样保存。但我无法加载具有多个选定值的数据行。
我可以像这样使用 jQuery 选择多个选项
$('#1000_1').val(["1","2"]);
但我不知道如何使用 PL/sql 从表中选择存储的值,然后设置使用 javascript 选择的选项。
我尝试在 apex_item.text 中加载数据(id="1000_11" for monday 等)并在“After Refresh”DA 中传输值以选择这样的列表:
var sel_opt = $('#1000_11').val();
if (sel_opt == "1,2")
{
$('#1000_1').val(["1","2"]);
}
else if (sel_opt == "1,3")
{
$('#1000_1').val(["1","3"]);
}
else if (sel_opt == "2,3")
{
$('#1000_1').val(["2","3"]);
}
else if (sel_opt == "1,2,"2","3"]);
}
它有效,但也许有更聪明的解决方案?
我在 https://apex.oracle.com/pls/apex/f?p=4550:1:0::::: 上创建了一个示例工作区
- 工作区:多选
- 用户名:dev
- 密码:newYears3problems
解决方法
我会为每个选择菜单创建 SELECT LIST 页面项目,并将它们的多选选项设置为 Yes。
然后我猜我在页面处理部分的某个地方需要这样的东西
declare
array apex_application_global.vc_arr2;
begin
array := apex_util.string_to_table (:P30_SELECT_LIST_1);
apex_collection.create_or_truncate_collection ('P30_SELECT_LIST_1');
apex_collection.add_members ('P30_SELECT_LIST_1',array);
end;
一次存储多个菜单项。
然后我会在我的查询中添加类似的内容
and ITEM_1 in (
select c001
from apex_collections
where collection_name = 'P30_SELECT_LIST_1'
)
我可能不明白你的问题,但根据我得到的部分,它是简单的 sql 查询。不需要js。