Open utterances-bot opened 2 years ago
Hi Vikas, Is there a typo here: DECLARE BEGIN IF APEX_COLLECTION.collection_exists(p_collection_name => 'CHECKBOX') THEN apex_collection.delete_collection ('CHECKBOX'); END IF; apex_collection.create_collection_from_query (p_collection_name => 'CHECKBOX', p_query => 'select ''N'' c001, EMPNO c001 from EMP', p_generate_md5 => 'YES' ); END;
Instead of p_query => 'select ''N'' c001, EMPNO c001 from EMP', it should be p_query => 'select ''N'' c001, EMPNO c002 from EMP',
Thanks Herve
this is pretty good but fix the reported issue above...thx.
Great post! I'm implementing it right now, but I think it's missing the update of selected flag to "N" when checking + unchecking. Regards, Jose.
Here you have the solution with a simplified approach, just if you want to update your article:
For the SQL in the IR
SELECT APEX_ITEM.CHECKBOX2(
p_idx => 1,
p_value => ac.seq_id,
p_attributes => decode(ac.c001, 'Y', 'CHECKED', 'UNCHECKED')
|| ' onclick = update_checkbox('''
|| ac.seq_id
|| ''');'
"SELECT"
.....
For the Javascript code in the "Function and Global Variable Declaration" of the page
function update_checkbox(p_seq) {
apex.server.process(
"CHECKBOX", {
x01: p_seq
}, {
dataType: 'text',
success: function(pData) {
console.log('---');
}
});
}
And finally, the code of the Ajax Callback
DECLARE
l_value VARCHAR2(1);
BEGIN
-- Read current value, to update with the opposite
SELECT decode(c001, 'N', 'Y', 'N')
INTO l_value
FROM apex_collections ac
WHERE collection_name = 'CHECKBOX'
AND ac.seq_id = apex_application.g_x01;
apex_collection.update_member_attribute(p_collection_name => 'CHECKBOX',
p_seq => apex_application.g_x01,
p_attr_number => 1,
p_attr_value => l_value);
EXCEPTION
WHEN OTHERS THEN
htp.p(dbms_utility.format_error_backtrace || SQLERRM);
END;
Preserve Checkbox state while Paginating in Interactive/Classic Report Oracle APEX - Ontoor Blogs
https://blogs.ontoorsolutions.com/post/preserve-checkbox-state/