Interactive Grid autosave and refresh (after processing) - oracle-apex

I have Interactive Grid with Static ID full_grid. For auto save I have dynamic action based on JavaScript Expression:
$('input[type=text]')
which saves grid details:
apex.region("full_grid").widget().interactiveGrid("getActions").invoke("save");
and it calls process - Interactive Grid - Automatic Row Processing (DML), with custom PL/SQL logic. This part is okay, everything working, but I have problem with data refresh. If I updating only one cell (row), everything is okay, because it updating only one row (last modified), but sometimes I need to update 1 or 2 additional rows when updated one of row. I mean if I have 10 rows, when I update 5th row, I update 2nd and 3rd rows as well (in database table), and after processing Interactive Grid is not updated visually for 2nd and 3rd rows. I understand that I have to refresh Interactive Grid after processing, but I don't have idea how I can do it. It is possible to call JavaScript function from PL/SQL or maybe there is another solution to refresh Interactive Grid after processing without page submit?

Try:
apex.region("full_grid").widget().interactiveGrid("getActions").invoke("selection-refresh");
for refresh current line, or
apex.region("full_grid").widget().interactiveGrid("getActions").invoke("refresh");
for full refresh.

Related

Formula help on IF ELSE on Smartsheet

I want to have a condition where IF Delivered column checkbox is checked, then that whole row will be deleted. Is that feasible?
How can I start with it?
Formulas can't change the condition of an item (like a row), only the value in a cell. So, in other words, you can't delete a row with a formula.
You "could" do this with an external script using the Smartsheet API, but you'll want to take situations that #Ken White mentioned in the comments into account. Your script should make sure that there is a way for users to recover the deleted row if the box is checked by mistake.
There are a couple of ways this might be possible. If you set up a default filter on a sheet to always load rows where complete box is unchecked, then, if you checked off a task or two and reloaded the sheet those tasks would not be visible the next time it loads.
To do this:
Create a new filter.
Title it and check the Share Filter checkbox
Set the criteria to the checkbox is unchecked
Then click okay
Save the sheet to save the shared filter.
Click on SHARE
Scroll down and click edit next to the default view
Set the filter to new filter you saved
Save.
Check off some boxes and save the sheet.
Reload the sheet and the completed items will not be visible.

Oracle/APEX Adding a row to an Interactive Grid with a Dynamic Action

Currently using APEX 5.1.4
My goal is to have the user press a button, which triggers a new row to be added to the bottom of the IG. This row would also need to have some default values pre-populated, such as the sequence column I have functioning as a primary key.
Doesn't matter how exactly, but I was considering doing it with Javascript. However, none of the methods I have found online, regarding adding a row with Javascript, work.
Also, I have the header bar of the IG removed, so finding the native Add Row Button probably is not an option.
--EDIT--
I found some Javascript that successfully allows me to add a row, however, it adds the row directly underneath the currently selected row. I do not see any methods to automatically select the last row of the IG, and it still doesn't solve that the row needs to have some dynamic values upon instantiation.
Here is the javascript:
This shows all of the available functions that can be invoked ( with .invoke() ):
apex.region("id-region-emp").widget().interactiveGrid("getActions").list()
These following lines both instantiate a new empty row on the IG:
("row-add-row" adds to top of IG, "insert-record" adds underneath currently selected row.)
apex.region("id-region-emp").widget().interactiveGrid("getActions").invoke("row-add-row")
apex.region("id-region-emp").widget().interactiveGrid("getActions").invoke("insert-record")
Better to use below code:
apex.region("detaildataset").widget().interactiveGrid("getActions").invoke("selection-add-row");
Before applying this code make interactiveGrid editable by clicking on attributes and also apply primary key on one column and then apply this code in Execute javascript code:
apex
.region("detaildataset")
.widget()
.interactiveGrid("getActions")
.invoke("selection-add-row");

How to set a value to an application item in oracle apex 5

I have several tabs. There is a date picker on each tab. I need that date to be the same on all tabs no matter what. So, if the user changes the date on Tab 1, then goes to tab 2, the date on tab 2 will have changed also. I have never created an application level item before and I thought that might be the most efficient way to accomplish what I need (by setting that item's value to the date the user selected). My problem is that I don't know how to set the value of the application item and also how to retrieve that value on another tab.
You didn't describe what exactly you're trying to do, but - if each tab represents its own table, why do you keep the same date value in all of them? Doesn't look like a normalized data model. Consider using a single date column (in one - master - table) and use (i.e. reference) it in others (i.e. details).
As of your question: How about creating a global page (i.e. page 0) and having a date picker item on it? You can display it on any other page you want. For example, if you set its value while on tab 1 and then move on to tab 3, you can again modify that value which will be visible on all other pages. Basically, you'd maintain just one item instead of as many as number of tabs involved. (BTW, doesn't that remind you of what I described in the first paragraph?).
Alternatively, create a date picker item on tab 1 page; on all other pages, create a "lookup" (display) item which would simply display what's been selected on tab 1. That's easy to do, just make its source to be an "Item", such as P1_DATE_ITEM.
In Shared Components > Application Items create new Item called G_DATE.
Then for every datepicker add Dynamic Action on Event Change.
In True action Set Value select Type PL/SQL Expression with code
:G_DATE := :P1_DATEPICKER1;
and Items to Submit :P1_DATEPICKER1
Next in every datepicker Source set Type PL/SQL Expression with code
:G_DATE
used Always (...)
Regards

How to combine tabular form and text area in one page?

I have a page, containing tabular data(region type SQL Query (updateable report)). It only updates existing rows using Submit. The wizard created ApplyMRU process. It works fine. But now I would like to place a text area in the same page, which will be bound to different table and will get updated once the same Submit button is pressed. How can I accomplish it?
I've created item for text area, but not sure what type of source I should set. Database column doesn't let me specify table. Also I guess I need a second after submit process, but not sure which one.
Keep your existing ApplyMRU infrastructure for the tabular form, and just define a second PL/SQL process that executes during page submit that will do whatever it is you want with your text area, eg:
insert into notes (id, text) values (:P1_ID, :P1_TEXT_AREA);
Take note of the order of the processes, as you may want to execute one before the other.

Copy Records in Oracle Apex

I need to copy selected row values and store as a new record.
I am using Oracle Apex 4.2 and Tabular Form.
I need to use checkbox to select the rows and button copy. When i select multiple rows followed by click copy button to copy all the selected row values as new rows and save.
Can anyone Help
Copying Records Through an APEX Tabular Form Input
The idea of cloning existing records from a single table through an Oracle APEX Tabular Form works without much interference with the default design that you can set up through the APEX wizard for page region content.
Build a table with an independent primary key.
Suggested to include two auxiliary columns: COPY_REQUEST and COPIED_FROM for running copy operations. Specific form elements will map to these columns on the tabular form that will be set up.
Build an Oracle stored procedure that can read which records need to be copied. This procedure will be invoked each time the SUBMIT button is pressed.
(optional) Consider including a suppression of step (3) in the event that there is nothing to process (i.e., no records marked for copying).
The Working Table for Receiving Input: COPY_ME
TIP: You will have an easier time if you use the standard TABLE creation wizard. Designate CUSTOMER_ID as the PRIMARY_KEY and have APEX create its standard auto-incrementing functionality on top. (sequence plus trigger set up.)
Here's the sample data I used... though it doesn't matter. You can put in your own values and be able to verify what happened easily.
The Heavy Lifting: The Stored Procedure for Cloning Records in COPY_ME
This procedure works with 1 or more records at a time with a special identifier in the COPY_REQUEST table. After the task is done, the procedure cleans up and resets the request value again.
create or replace procedure proc_copy_me_request is
c_request_code CONSTANT char(1):= 'Y';
cursor copy_cursor is
SELECT cme.CUSTOMER_ID, cme.CUSTOMER_NAME, cme.CITY, cme.COUNTRY,
cme.COPY_REQUEST
FROM copy_me cme
WHERE cme.COPY_REQUEST = c_request_code
FOR UPDATE OF cme.COPY_REQUEST;
BEGIN
FOR i in copy_cursor LOOP
INSERT INTO copy_me (customer_name, city, country, copied_from)
VALUES (i.customer_name, i.city, i.country, i.customer_id);
UPDATE copy_me
SET copy_request = null
WHERE CURRENT OF copy_cursor;
END LOOP;
COMMIT;
END proc_copy_me_request;
There is also a column that can be hidden. It tracks where the record was originally copied from.
Note that the cursor is using the FOR UPDATE OF and WHERE CURRENT OF notation. This is important because the procedure is changing the records that are referenced by it.
APEX Page Setup Instructions
Set up a standard FORM type page and choose the TABULAR FORM style. Follow the set up instructions, taking care to map the correct primary key, and also to the PK sequence object created with the table in the previous steps above.
This is what your page set up will look like after these steps are completed:
EDIT The COPY_REQUEST Form Value:
Under the column attributes section, change the Display As option to "simple checkbox"
Under the list of values section, put a single value under the LOV Definition: Y (case sensitive in either way... just be consistent)
EDIT The COPIED_FROM Form Value:
Under the column attributes section, change the Display As option to "Display as Text(Saves State)". This is just to prevent users from stepping on this read-only field. You could also suppress it if it isn't important to know.
CREATE a New Process: Execute Copy Procedure
This is the bottom of the same configuration page, there are very few things to change or add:
Demonstration: Screenshot of COPY_ME Tabular Form Page in Action
The first screenshot below is before the page is tidied up and the checkbox control is put into place.
Plug in some test data and give it at try. The Page Process created in the step above conditionally invokes the stored procedure that processes all copy requests made at the same time when the SUBMIT form button is selected.
COMMENTS: If you spend enough time tinkering around with the built-in wizards in Oracle APEX, there are opportunities to learn new design patterns and process flows compatible within the tool. Adapting your approach can reduce the amount of additional work and frustration.