JqGrid, shows success in loading, but does not mount to Grid

2

I have grid on my site that I use JqGrid . What is happening is that when the data comes back from the request, they are formatted correctly because the JqGrid itself enters the loadComplete method, however, it does not load that data into the Grid.

JqGrid Javascript.

    $(document).ready(function () {
    $("#jqGrid").jqGrid({
        url: 'adm/controller/medico.php?acao=listarMedico',
        mtype: "POST",
        styleUI : 'Bootstrap',
        datatype: "json",
        colModel: [
            { label: 'id', name: 'idMedico', key: true, width: 75, hidden:true },
            { label: 'Nome', name: 'nomeMedico', width: 75 },
            { label: 'CRM', name: 'crmMedico', width: 150 },
            { label: 'Especialidades', name: 'especialidadesMedico', width: 150 },
            { label: 'Endereço', name: 'enderecoMedico', width: 150 },
            { label: 'Telefone', name: 'telefoneMedico', width: 150 }
        ],
        viewrecords: true,
        rowNum: 20,
        rowList: [20, 40, 100],
        //height: "auto",
        height: 400,
        emptyrecords: "Nenhum médico com o filtro selecionado",
        loadtext: "Buscando e carregando...",
        rowNum: 20,
        pager: "#jqGridPager",
        caption: "Médicos Conveniados",
        loadComplete: function(data){
            console.log('sucesso');
            console.log(data);
        },
        loadError: function (xhr,st,err) {
            console.log('HTTP status code: ' + xhr.status + '\n' +
                  'textStatus: ' + st + '\n' +
                  'errorThrown: ' + err);
            console.log('HTTP message body (jqXHR.responseText): ' + '\n' + xhr.responseText);
        }
    });
});

The return that PHP brings me and this in JSON:

{
  "total": 1,
  "page": 1,
  "records": 20,
  "rows": {
    "1": {
      "id": "1",
      "cell": {
        "idMedico": "1",
        "nomeMedico": "dsda",
        "crmMedico": "jknjk",
        "especialidadesMedico": null,
        "enderecoMedico": " ,  -  - ",
        "telefoneMedico": "() "
      }
    },
    "2": {
      "id": "2",
      "cell": {
        "idMedico": "2",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": " ,  -  - ",
        "telefoneMedico": "() "
      }
    },
    "3": {
      "id": "3",
      "cell": {
        "idMedico": "3",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": " ,  -  - ",
        "telefoneMedico": "() "
      }
    },
    "4": {
      "id": "4",
      "cell": {
        "idMedico": "4",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": " ,  -  - ",
        "telefoneMedico": "() "
      }
    },
    "5": {
      "id": "5",
      "cell": {
        "idMedico": "5",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - \u00c1gua Doce do Norte  - ES",
        "telefoneMedico": "() "
      }
    },
    "6": {
      "id": "5",
      "cell": {
        "idMedico": "5",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - \u00c1gua Doce do Norte  - ES",
        "telefoneMedico": "() "
      }
    },
    "7": {
      "id": "5",
      "cell": {
        "idMedico": "5",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endereco , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "() "
      }
    },
    "8": {
      "id": "5",
      "cell": {
        "idMedico": "5",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endereco , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "() "
      }
    },
    "9": {
      "id": "6",
      "cell": {
        "idMedico": "6",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": " ,  -  - ",
        "telefoneMedico": "() "
      }
    },
    "10": {
      "id": "7",
      "cell": {
        "idMedico": "7",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": " ,  -  - ",
        "telefoneMedico": "() "
      }
    },
    "11": {
      "id": "8",
      "cell": {
        "idMedico": "8",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "() "
      }
    },
    "12": {
      "id": "8",
      "cell": {
        "idMedico": "8",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "() "
      }
    },
    "13": {
      "id": "9",
      "cell": {
        "idMedico": "9",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "() "
      }
    },
    "14": {
      "id": "9",
      "cell": {
        "idMedico": "9",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endereco , Bairro - \u00c1gua Doce do Norte - ES",
        "telefoneMedico": "() "
      }
    },
    "15": {
      "id": "10",
      "cell": {
        "idMedico": "10",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "(81) 98125-8886"
      }
    },
    "16": {
      "id": "10",
      "cell": {
        "idMedico": "10",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endereco , Bairro - \u00c1gua Doce do Norte - ES",
        "telefoneMedico": "() "
      }
    },
    "17": {
      "id": "11",
      "cell": {
        "idMedico": "11",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "(81) 98200-5300"
      }
    },
    "18": {
      "id": "11",
      "cell": {
        "idMedico": "11",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "(81) 98125-8886"
      }
    },
    "19": {
      "id": "11",
      "cell": {
        "idMedico": "11",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endereco , Bairro - \u00c1gua Doce do Norte - ES",
        "telefoneMedico": "() "
      }
    },
    "20": {
      "id": "12",
      "cell": {
        "idMedico": "12",
        "nomeMedico": "Henrique",
        "crmMedico": "CRM",
        "especialidadesMedico": null,
        "enderecoMedico": "Endere\u00e7o , Bairro - Afonso Cl\u00e1udio - ES",
        "telefoneMedico": "(81) 98200-5300"
      }
    }
  }
}

Would anyone know why JqGrid is not mounting the data in the Grid?

    
asked by anonymous 21.01.2016 / 22:43

1 answer

1

The issue has been resolved. I asked the same question in the stackoverflow in English , and the response they gave me helped me solve the problem. In my JSON I did not mount the rows the way the JqGrid expects it to be in the rows key to be this way:

[
    {"idMedico":"1",...},
    {"idMedico":"2",...},
    ...
    {"idMedico":"12",...}
]
To get this, in PHP I created the key rows in array X, I mounted a array separated with the lines I wanted and gave array_push passing array X and specifying key rows .

    
22.01.2016 / 14:19