April 10, 2023
To set values in an interactive grid in Oracle Apex using JavaScript, you can use the model
and setValue
functions.
Here's an example code snippet that sets the value of the first row in an interactive grid with the column name EMP_NAME
to "John":
1var model = apex.region("my_interactive_grid").widget().interactiveGrid("getViews", "grid").model;
2model.setValue(model.getCell([0, "EMP_NAME"]), "John");
3
In the above code, replace my_interactive_grid
with the Static ID of your interactive grid region. The getCell
function is used to get the cell object for the specified row and column, and the setValue
function sets the value of that cell.
You can also loop through all the rows in the interactive grid and set values for each row. Here's an example code snippet that sets the value of the EMP_NAME
column to "John" for all the rows in the interactive grid:
javascript
1var model = apex.region("my_interactive_grid").widget().interactiveGrid("getViews", "grid").model;
2var rowCount = model.getTotalRecords();
3for (var i = 0; i < rowCount; i++) {
4 model.setValue(model.getCell([i, "EMP_NAME"]), "John");
5}
6
Again, replace my_interactive_grid
with the Static ID of your interactive grid region. The getTotalRecords
function is used to get the total number of rows in the interactive grid. The loop iterates through all the rows and sets the value of the EMP_NAME
column to "John" for each row.
No posts found in the category "Oracle apex"