Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

559
Visualizações
Jqgrid edittype : select editoptions: dataUrl is not called to populate the data

I am trying to populate one of the columns using select box in jqgrid. Below is the code.

$(document).ready(function(){
    
    $("#grid").jqGrid({
        url: "./info",
        datatype: "json",
        mtype: "GET",
        ajaxSelectOptions:{
            type: "GET",
            dataType: "json",
            success: function (result) {
                console.log(result);
            }
        },
        colNames: ["DeptId", "DeptName", "StuId", "StuName", "StuDoj"],
        colModel: [
            { name: "deptId", hidden:true },
            { name:"deptName", width:90, editable:true, edittype:'select', formatter:'select', editoptions:{
                dataUrl:'./getDepts',
                buildSelect: function(res){
                    console.log(res);
                    var s='<select id="dept" name="dept">'
                    $.each(res,function(idx,obj){
                        $('#dept')
                          .append($('<option>', { value : obj.deptId })
                          .text(obj.deptName));
                    }); 
                    return s+"</select>";
                }
            }},
            { name: "studentId", hidden:true },
            { name: "studentName", width: 80,editable:true },
            { name: "studentDoj",width: 90,editable:true }
        ],
        pager: "#pager",
        rowNum: 5,
        rowList: [5, 10, 20],
        sortname: "empId",
        sortorder: "asc",
        sortable:true,
        viewrecords: true,
        gridview: true,
        caption: "MyGrid",
        jsonReader: {
            repeatitems: false,
            id: "empId",
            root: function (obj) { return obj; },
            page: function (obj) { return 1; },
            total: function (obj) { return 1; },
            records: function (obj) { return obj.length; }
        }
    }); 
    $("#grid").jqGrid('navGrid','#pager',{add:false,view:true,search:true});

})

In the editOptions for colModel 'deptName' the dataUrl is not called to populate the select box. The jqgrid is populated using /info resturl which fetches the deptName for a particular student. I want the deptName to be of type select box and its value should be same as deptName fetched using info rest url

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It should be called, but your data will be newer filled, since you overwrite the success function in ajaxSelectOptions.

In order to get response, please comment the success function or remove it

$("#grid").jqGrid({
    url: "./info",
    datatype: "json",
    mtype: "GET",
    ajaxSelectOptions:{
        type: "GET",
        dataType: "json"
    },
    ....
});

UPDATE: With small changes your code is working fine. Here is a link to your code

Note that the formatter does not have option dataUrl. It is only available in in editing.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda