APEX

Entering edit in a cell on pageload

I recently wrote about how you set focus on a certain cell in an interactive grid. As often is the case, a solution may work well in many cases but there are some cases where something additional is needed. Say that getting one cell in an interactive grid is what you of want, but some cases are so obvious that the user would want to edit a certain cell once the grid is loaded with data.

In this case we can use the setup in the last post to in addition to making the cell focused also be opened such that the contents is ready to be changed.

Again the region with the interactive grid is given a static id of ABC. Then a dynamic action is created for “Page Change [Interactive Grid]” with the action being “Execute JavaScript code”. The code we need there is the following.

var ig = apex.region("ABC").widget().interactiveGrid("getViews","grid");
var rec = ig.model.recordAt(2);
ig.view$.grid("gotoCell", rec[0], "ORDER_DATETIME");
ig.view$.find(".a-GV-cell.is-focused").trigger("dblclick");

As before ABC is the static id for the IG region. rec refers to the third record in the IG. With that the cell with the column ORDER_DATETIME is set to be in focus.

The last line then finds the focused cell and triggers a double click on it, effectivly placing it in edit with the contents selected. Since this is a dat column it results in the date picker being loaded för changing the data in the cell.

It results in the following right after loading the page with no other action from the user.

As you can see the page opens the cell for ORDER_DATETIME in the third record in the interactive grid right after the page is loaded.

For a user that always changes the same cell when they open an interactive grid this is of course much nicer than having to find the mouse and double click in the same cell every time.

Leave a Comment

Your email address will not be published. Required fields are marked *

*