-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax_callback.txt
110 lines (84 loc) · 3.12 KB
/
ajax_callback.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
CREATE TABLE APPROVAL_REQUESTS (
REQUEST_ID NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
REQUEST_NAME VARCHAR2(100) NOT NULL, -- Name or description of the request
REQUEST_DATE DATE DEFAULT SYSDATE, -- Date when the request was created
STATUS NUMBER DEFAULT 0, -- Request status: 0 = Pending, 1 = Approved, 2 = Rejected
CREATED_BY VARCHAR2(50), -- User ID or name of the person who created the request
APPROVED_BY VARCHAR2(50), -- User ID or name of the person who approved the request (NULL when pending)
APPROVED_DATE DATE -- Date when the request was approved (NULL when pending)
);
-- Sample Data Insertions
INSERT INTO APPROVAL_REQUESTS (REQUEST_NAME, CREATED_BY)
VALUES ('Project Proposal Submission', 'Alice');
INSERT INTO APPROVAL_REQUESTS (REQUEST_NAME, CREATED_BY)
VALUES ('Budget Approval Request', 'Bob');
INSERT INTO APPROVAL_REQUESTS (REQUEST_NAME, CREATED_BY)
VALUES ('Annual Leave Application', 'Charlie');
INSERT INTO APPROVAL_REQUESTS (REQUEST_NAME, CREATED_BY)
VALUES ('Conference Attendance Request', 'Diana');
INSERT INTO APPROVAL_REQUESTS (REQUEST_NAME, CREATED_BY)
VALUES ('Resource Allocation Request', 'Eve');
Classic Report
------------------------
select REQUEST_ID,
REQUEST_NAME,
REQUEST_DATE,
STATUS,
CREATED_BY,
APPROVED_BY,
APPROVED_DATE,
APEX_ITEM.CHECKBOX2(
p_idx => 1,
p_value => REQUEST_ID,
p_attributes =>
'style="width:30px;height:30px;" ' ||
CASE
WHEN STATUS = 1 THEN ' CHECKED DISABLED ' -- Checked and disabled if STATUS=1
ELSE '' -- Unchecked and enabled for other cases (e.g., STATUS=0 or NULL)
END,
p_checked_values => NULL,
p_checked_values_delimiter => ':',
p_item_id => 'f01_' || LPAD(ROWNUM, 4, '0'),
p_item_label => NULL
) AS APPROVAL_STATUS
from APPROVAL_REQUESTS
AJAX_CALLBACK
------------------------
DECLARE
l_application_id NUMBER := TO_NUMBER(apex_application.g_x01);
BEGIN
update APPROVAL_REQUESTS
set STATUS=1,
APPROVED_BY=:APP_USER,
APPROVED_DATE=SYSDATE
where REQUEST_ID=l_application_id;
COMMIT;
END;
Dynamic Action
------------------------
Event : Change
Selection Type : jQuery Selector
jQuery Selector : input[id*="f01_"]
Execute JavaScript
------------------------
var v_obj_id,v_obj_val;
//
v_obj_id = 0;
v_obj_val = 0;
v_obj_id = this.triggeringElement.id;
v_obj_val = this.triggeringElement.value;
// Send an Ajax callback to the server
apex.server.process(
"AJAX_CALLBACK",
{
x01: v_obj_val // Pass the value to the server
},
{
dataType: "text" // Specify the expected data type of the response
}
).done(function(pData) {
// Trigger refresh for the content named 'SCHEDULE'
$('#APPROVAL').trigger('apexrefresh');
// Optional: Handle the response here if needed
console.log("Ajax callback successful, response: " + pData);
});