mardi 16 juillet 2019

How does jqGrid dynamically populate the list of options based on status data?

I am currently using jQgrid to draw a list and data is being retrieved through Ajax. I'm getting the list back normally, and there's nothing wrong with it.

My problem is that I have to dynamically populate the list of options based on the status value I'm getting.

A place to call data:

$(function(){

    search_provider();


    // grid resize
    $(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)
            }
        }
    })  
}

a place to be filled dynamically:

{
            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) {
                        ...
                    }
                }]
            }
        }

It is now showing all the lists.

When the value of approval_status is '0' return "0:Unauthorized;1:Approval;2:Hold;3:Denial of approval"

When the value of approval_status is '1' return "1:Approval;4:Reclamation"

When the value of approval_status is '2' return "1:Approval;2:Hold;3:Denial of approval"

When the value of approval_status is '3' return "1:Approval;2:Hold;3:Denial of approval"

I want to be changed as above. How can you solve this problem?

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire