What method does jqGrid use to dynamically update the selection options list based on the status data?

Currently, I am utilizing jQgrid for displaying a list with data retrieved through Ajax. The list is displaying properly without any issues.

However, my challenge lies in dynamically populating the list of options based on the status value received.

Area for fetching data:

$(function(){

    search_provider();


    // resizing grid
    $(window).on('resize.jqGrid', function() {
        $("#requestList").jqGrid('setGridWidth', $(".grid-cover").width());
    })


});

function search_provider() {


    var queryData = $("#searchList").serialize();

    $.ajax({
        url : "/v1/point/admin/provider/game_provider_list",
        type : "GET",
        dataType : "json",
        data: queryData,
        success : function(result) {
            $("#resultLength").text(result.jqgrid_data.length);
            if(result.jqgrid_data.length == 0){
                noData();
            }else{
            $('#grid-cover').show();
            $('#no-data').hide();
            setRequestList(result.jqgrid_data)
            }
        }
    })  
}

Area to be dynamically filled:

{
                name : 'approval_status',
                index : 'approval_status',
                align : 'center',
                editable : true,
                edittype : 'select',
                formatter : 'select',
                editoptions : {
                    value : "0:Unauthorized;1:Approval;2:Hold;3:Denial of approval;4:Reclamation",
                    dataEvents : [{
                        type : 'change',
                        fn : function(e) {
                            ...
                        }
                    }]
                }
            }

The lists are currently being displayed.

For approval_status value '0', display

"0:Unauthorized;1:Approval;2:Hold;3:Denial of approval"

For approval_status value '1', display "1:Approval;4:Reclamation"

For approval_status value '2', display

"1:Approval;2:Hold;3:Denial of approval"

For approval_status value '3', display

"1:Approval;2:Hold;3:Denial of approval"

I wish to make the above changes. What would be the solution to this issue?

Answer №1

To retrieve data from the database, make sure the data variable imported from the DB has the same name. Create a conditional statement based on the status value to fetch DB data that meets specific criteria. Display the data using a customized JQgrid.

MyBatis.xml

select id="list" parameterType="hashmap" resultType="hashmap">
            <choose>
                <when test='approval_status == "0"'>
                                            SELECT
        seq_no AS col1, 
        nick_name AS col2,
        ...
        FROM DB_DB
                <when test='approval_status == "1"'>
                                                                SELECT
         seq_no AS col1, 
         ............
         </choose>

JQgrid.js

function setRequestList(jqgrid_data,status){
    var title = [];
    if(status == '0'){
        title = ['No', 'nick',... ];
    }else if(status == '1'){
        title = ['No', 'name', ... ];
    }
    var colmodel = [];
    $("#requestList").jqGrid("GridUnload");
    jQuery("#requestList").jqGrid({
        data : jqgrid_data,
        datatype : "local",
        height : 'auto',
        colNames : title,
        colModel : [{
            name : 'col1',
            index : 'seq',
            align : 'center',
            sortable : false
        }
        ...

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

What could be causing the return of undefined upon execution?

function updateTitle(title) { title = "updated title"; } var currentTitle = "original title"; currentTitle = updateTitle(currentTitle); console.log(currentTitle) I'm just starting to learn JavaScript and I'm curious about why this code behav ...

unable to perform a specific binary operation

Is there an efficient method to achieve the following using binary operations? First byte : 1001 1110 Second byte : 0001 0011 Desired outcome : 1000 1100 I am looking to reset all bits in the first byte that correspond to bit values of 1 in the secon ...

Ways to successfully pass multiple parameters in Nuxt

Within Nuxt.js, when working with the code in pages/posts/_id.vue, it looks like this: <template> ...

"Enhance Your Form with Ajax Submission using NicEdit

Currently, I am utilizing nicEditor for a project and aiming to submit the content using jQuery from the plugin. Below is the code snippet: <script type="text/javascript"> bkLib.onDomLoaded(function() { new nicEditor().panelInstance('txt1' ...

The background image shifts dynamically with a parallax effect as the page is scrolled

I need help solving a parallax issue that I'm currently facing. On my webpage, I have a background image positioned at the top with a parallax effect achieved through background-position: fixed. However, I now require the image to scroll along with t ...

Having difficulty resolving all parameters for the component: (?, [object Object]) in the Jasmine component Unit Test

While defining a UT for a component with an extended class using i8nService and ChangeDetectionRef, I encountered an error preventing me from instantiating it: Failed: Can't resolve all parameters for BrandingMultiselectComponent: (?, [object Object] ...

What could be the reason my form inputs are not capturing any data?

I am currently working with React to build a form, but I am facing an issue. Whenever I try to type in the form fields, nothing seems to happen. Upon inspecting the state of each input in the React dev tools, I noticed that it is only capturing one letter ...

Java streams: concise way to execute numerous mathematical operations on an Int stream

After learning about Java 8, I have yet to try it out myself. To test my skills, I decided to perform basic math operations using this technology. My goal is to calculate the average, sum, maximum, and minimum of a list using Java 8's new techniques. ...

Issue with Scrollspy Functionality in Bootstrap 4

Scrollspy feature isn't working in my code. <nav class="navbar navbar-expand-lg fixed-top navbar-dark" role="navigation"> <div class="container"> <a class="navbar-brand" href="#featured"><h1></h1></a> < ...

Acquiring the selector value from a tag

To summarize: This snippet of code: for(let i = 0; i <= items.length; i++){ console.log(items[i]) } Produces the following output: <a class="photo ajax2" target="_blank" href="/profile/show/3209135.html" data-first="1" data-next="3206884"> ...

Delete a filename in Internet Explorer with the power of JavaScript and jQuery

In my attempts to clear the file input field in IE using $('#files').val('');, I found that it was not effective. $('#uploadimgdiv').html(''); var fil1 = document.getElementById("files"); $('#fil1').val(&a ...

How can I transfer a MongoDB collection to an EJS file in the form of a sorted list?

I have successfully displayed the collection as a json object in its own route, but now I want to show the collection in a list under my index.ejs file (I'm still new to ejs and MongoDB). Below is the code that allows me to view the json object at lo ...

Linking to a Different Tab without Tab Mutation with Bootstrap 3.3.5

I am facing a similar issue to the mentioned questions. I am trying to use a link to change tabs, but the problem is that the link only changes the tab content and not the active tab. The most similar question can be found at: Bootstrap linking to a tab w ...

What is the best way to distinguish between the value of $typ = $POST['type'] and the chosen type of leave?

Access Leave Entry Form I'm struggling to find a way to compare the selected leave type $typ === 2 with the Sick leave id. The $typ = $_POST['typ'] stores the leave type obtained from a database, such as Annual leave and Sick Leave. If I se ...

Alter the background color of a React application with a single click in a spontaneous manner

When I attempted to change the background color of the entire page randomly by clicking a button, it only changed the background of the div element. Here is the code snippet I used: import React from "react"; class Home extends React.Component { ...

Refreshing the page using AJAX in WooCommerce after executing my custom script

I am experiencing an issue with WooCommerce. I am trying to incorporate a custom jQuery script that executes after clicking the add to cart button. When I do not include my script, everything functions properly - the AJAX request triggers and the product i ...

Unexpected provider error in AngularJS when using basic module dependencies

I am encountering an issue with my module setup involving core, util, and test. The util module has no dependencies and one provider The test module depends on util and core, and has one controller The core module depends on util, and has a provider that ...

JavaScript class syntax allows for the definition of inherited instance fields

In the code snippet below, I have implemented a way to define a prototype with a simple property that can be inherited by objects using the prototype: const SCXMLState = Object.setPrototypeOf( Object.defineProperties({ addChild() { } isStat ...

Invoking a JavaScript function using jQuery's AJAX

I'm currently working with jQuery and Ajax. Within my MainFile, I have the following code: <html> <head> <script src="Myscript.js"> </script> <script type="text/javascript"> $(doc ...

JavaScript validation failing to validate number ranges for 4-digit numbers

Currently, I am facing an issue with validating numbers entered between two text boxes to ensure that the first number is not greater than the second number. The validation process seems to work fine for three-digit numbers (e.g., 800 - 900), but it fails ...