What is the best way to perform a table update in the interactive grid within Oracle APEX using AJAX requests directly from the

I have a unique requirement where I need to utilize two Interactive Grids to showcase my data. However, I am facing challenges in displaying the data and performing DML operations on the selected grid using Ajax from the backend. Despite attempting SQL and PLSQL approaches, I have not been able to achieve the desired output.

function makeCellsReadOnly() { 
    var grid   = apex.region("readonly_emp_ig_id").widget().interactiveGrid("getViews","grid");
    var model  = grid.model;
    var recordValue;

    model.forEach(function(record, index, id) { 
        
        // getFieldKey method retrieves the index used for a given field name when accessing that field of a record. This allows access to a specific record field.
        recordValue = record[model.getFieldKey("VALIDATED")];  
        var metadata   = model.getRecordMetadata(id);
        var fieldsObj = metadata.fields;

        if (!fieldsObj) {
            fieldsObj = metadata.fields = {};
        }

        if (!fieldsObj["EMPNO"] || !fieldsObj["JOB"] || !fieldsObj["MGR"] || !fieldsObj["ENAME"] ) {

            fieldsObj["EMPNO"] = {}; 
            fieldsObj["JOB"] = {}; 
            fieldsObj["MGR"] = {}; 
            fieldsObj["ENAME"] = {}; 
        }

        // using Object.keys(recordValue)[0] to fetch value
        if (recordValue[Object.keys(recordValue)[0]] === 'Y') {
            // set fields to read-only
            fieldsObj["EMPNO"].ck = 1; 
            fieldsObj["JOB"].ck = 1;  
            fieldsObj["MGR"].ck = 1; 
            fieldsObj["ENAME"].ck = 1;   
            
            // trigger the change
            model.metadataChanged(id); 
        } else  {
            fieldsObj["EMPNO"].ck = ""; 
            fieldsObj["JOB"].ck = "";  
            fieldsObj["MGR"].ck = ""; 
            fieldsObj["ENAME"].ck = "";  

            model.metadataChanged(id); 
        }
    });     
}

Answer №1

Once you have set the data values in the records of the Interactive Grid using the model (your code looks good up to this point); you can execute

apex.region("your_grid").widget().interactiveGrid("getActions").invoke("save");

To trigger the save action for the interactive grid.

Remember: The "SAVE" option of the grid must be enabled in order to trigger it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Duplicate a DOM element and incorporate animation into it

After extensively researching articles and documentation on this topic, I have yet to find a solution that aligns with the approach I am attempting to implement. My scenario involves an array of category items which contain a nested array of products be ...

Linking NPM to the source directory rather than the library directory

Currently, I am juggling multiple NPM modules simultaneously - one central module that brings in three others. To establish connections between them, I have utilized npm link. However, all the modules are being developed using Babel for source transpilat ...

How can I color the first, second, and third buttons when the third button is clicked? And how can I color all the buttons when the fourth button is clicked?

I am trying to achieve a task with 4 buttons. When the third button is clicked, I want the first, second, and third buttons to change color. Similarly, when the fourth button is clicked, I want all buttons to change color. Additionally, I need to save a va ...

Using event.preventDefault() for Form validation in Reactjs as default

My goal is to avoid submitting the form when clicking on submit. To achieve this, I am utilizing the following: onSubmit (e) { e.preventDefault(); console.log(this.state); } <form className="loginform"> <h1 className="log ...

Modify a property within an object stored in an array using React with Redux

When trying to dispatch an action that updates values in the redux state by passing an array, I encountered an issue. It seems that despite attempting to update the array by changing object values, I kept facing this error - "Cannot assign to read only pro ...

Ensure that Bootstrap rows and columns are properly lined up with their respective fields

Currently, I am experimenting with Bootstrap's responsive columns and rows. In order to understand how it functions, I have set up labels and fields. My main challenge now is aligning the text-fields with their respective labels. Despite referring to ...

I encountered an issue with the "props map error" while working on this

Hello everyone, I am currently in the process of learning React by creating a toggle button for switching between light and dark modes. However, I have encountered an issue when attempting to map through the state and display the data in card format (altho ...

Troubleshooting jQuery and CSS problems related to window size discrepancies

My website dynamically calculates the size of each div based on the window size... // Functions to begin $(document).ready(function(){ $('.wrapper').css({'top' : '0px','left' : '0px'}); $(&ap ...

Converting values to hexadecimal in PHP inspired by Javascript's .toString(16)

Is there a way to achieve the same result as JavaScript's .toString(16) in PHP? var n = 200000002713419; console.log(n.toString(16)); When executed, this code returns b5e6211de74b. Is there any equivalent function in PHP to achieve the same output? ...

Unable to assign attribute following discovery

Can the attribute of an anchor element that is found using find() be set? I attempted this: $(this).children('a').setAttribute("href","a link"); Although it does locate the anchor element, why am I receiving an error when trying to use setAttr ...

difficulty in making an https request

My application was developed using OFFICEjs and was functioning properly on LOCALHOST. However, last week it suddenly started throwing an error message - "XHR Error." This issue arose out of nowhere, as I hadn't made any changes to the code over the w ...

Alter the subview in real-time

When using EmberJs, I need to develop a view that can hold different types of players (such as Youtube, Photosynth, Html Content, etc.) and it should change dynamically based on a controller property that specifies the item to play. I've already crea ...

unable to retrieve the li element's ID when clicked

I am working on a code snippet to display tabs with dynamic content. $start = strtotime($_GET['date']); $dates = array(); for ($i = 0; $i <= 7; $i++) { $date = date('Y-m-d', strtotime("+$i day", $start)); $date1 = $ ...

Finding the largest number that is less than a specified variable within an array

I have a JavaScript array and a variable, set up like this; var values = [0, 1200, 3260, 9430, 13220], targetValue = 4500; How can I efficiently find the largest value in the array that is less than or equal to the given variable? In the provided ex ...

Alphabetic divider for organizing lists in Ionic

I am currently working with a list in ionic that is fetched from a controller and stored in localStorage. My goal is to add alphabetic dividers to the list, but I am facing some confusion on how to achieve this. Here is a snippet of the code: app.js $ion ...

Display drop-down item when selected for the first time and hide it when selected for the same item for the second time

Is there a way to display form input when "C" is selected and hide it when "A", "B", or "D" are selected? If "C" is selected again after initially showing the form input, should it be hidden? For example, if "C" is selected for the first time, the form inp ...

JQuery appended Bootstrap Modal to Body, but it refuses to close

After going through the process of appending the modal to the body and getting the text box working, I encountered an issue when trying to close it on the AJAX success event - none of my attempted solutions seem to be effective. var id; var refundAmount ...

Reversing the order of images on overlapping canvas

When I utilize the following code to draw on my HTML5 canvas: <canvas id="game">Your browser can't use canvas</canvas> <script> var canvas = document.getElementById('game'); var ctx = canvas.getContext('2d'); var ...

Is there a way to use jQuery to populate a textarea with text from a MySQL database that includes line breaks?

For the sake of cleanliness in my code, I have decided to set default values for each element in a form using jQuery. For example, my form elements look like this: <input name="mobile" id="mobile" type="text" /> In a separate JavaScript file, I fe ...

Angular filter that replaces underscores with spaces

Looking for a solution to replace underscores with spaces in a string ...