JQGRID change the color of the line or data if the return is NULL or White

Asked

Viewed 204 times

0

Could I condition a different color if a column is blank in GRID?
Something like this: if Shop ="", red line color

 $table.jqGrid({
        url: url,
        datatype: 'json',
        mtype: 'GET',  
        postData: {
            representante: function () { return jQuery("#representante option:selected").val(); },
            vendedor: function () { return jQuery("#vendedor option:selected").val(); },
            nome: function () { return jQuery("#nome").val(); }
        }, 
       colModel: [
           { label: 'RECNO', name: 'RECNO', width: 80 },
           { label: 'Cliente', name: 'CLIENTE', width: 80 },
            { label: 'Loja', name: 'A1_LOJA', width: 80 },
            { label: 'Nome', name: 'A1_NOME', width: 350 },
            { label: 'CNPJ', name: 'A1_CGC', width: 120 },
            { label: 'Municipio', name: 'A1_MUN', width: 150 },
            { label: 'Telefone', name: 'A1_TEL', width: 80 },

        ],
         viewrecords: true,
            rowNum: 20,
            rowList: [20, 40, 100],
            height: "auto",
            //height: 400,
            emptyrecords: "Nenhum Cliente",
            loadtext: "Buscando e carregando...",
            //rowNum: 20,
            pager: "#jqGridPager",
            loadonce: true

    });

The image shown, would have to come with the second red line. Since it brought the two blank fields.inserir a descrição da imagem aqui

1 answer

0


To whom it may interest, add in the event loadComplete and put your condition, picking up the line and changing its character

 loadComplete: function() {
             var rowIDs = jQuery("#jqGrid").getDataIDs();   //busca ids das linhas do grid

             for (var i = 0; i < rowIDs.length; i++) {     //entra nas linhas
                 var rowData = $("#jqGrid").jqGrid('getRowData', rowIDs[i]);   
                 //verifica se o campo está vazio (coloque sua condição)
                 if (rowData["A1_LOJA"] == "") {          
                        console.log("recno: ", rowData["RECNO"]);
                        // Muda a cor da Linha 
                        $(this).jqGrid('setRowData', rowIDs[i], false, {background:'#ee993d', color:'#fff'});
                 }
             }
          },

Browser other questions tagged

You are not signed in. Login or sign up in order to post.