The values ​​in the "grupo" column disappear when create and update

The values ​​in the "grupo" column disappear when create and update

klermannklermann Posts: 277Questions: 67Answers: 1

Hi, Allan. when I update or create a new item in the datatable, the values ​​in the "group" column disappear, disappear! Can you give me an idea of ​​what?
login: admin@admin.com
pass: admin
ec2-34-224-65-226.compute-1.amazonaws.com:8080/financeiro/despesas/

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Have you resolved this since posting your question? I've just tried adding a row and the information in the "Grupo" column doesn't disappear for me.

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1
    edited February 2018

    When I click on 'pendente' or 'paga' to edit the item. the item in the 'Grupo' column and disappears
    https://prnt.sc/ikuxdt

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Thank you for the instructions. The issue is the use of fnCreatedCell to set the contents of the cell:

                    { "data": "grupoDespesas.nomeGrupoDespesas",
                        "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                            $(nTd).html("<a class='hightlight' href='../grupos/'>" + oData.grupoDespesas.nomeGrupoDespesas +
                                    " <i class='fa fa-external-link font-size-10' aria-hidden='true'></i></a>");
                        }
    

    That callback function is only executed when the cell is created (i.e. once). Any other update is going to replace the contents of that with whatever the data property points to.

    You should use columns.render as you have done in the other columns to create the content for the cell, not the createdCell callback.

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1
    edited March 2018

    And now return null:

    { "data": "grupoDespesas.nomeGrupoDespesas",
                        render: function(data, type, row){
                          var nomeGrupo = data;
                          var grupo = "<a class='hightlight' href='../grupos/'>" + nomeGrupo +
                            " <i class='fa fa-external-link font-size-10' aria-hidden='true'></i></a>";
                          return grupo;
                      }
                    },
    

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Can you update the link to include that code please? The link above is still using fnCreatedCell.

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    Hello Allan, update link:
    login: admin@admin.com
    pass: admin
    ec2-34-224-65-226.compute-1.amazonaws.com:8080/financeiro/despesas/

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    grupoDespesas.nomeGrupoDespesas is null in the data being returned from the server after the edit:

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1
    edited March 2018
    var nomeGrupo = "";
                              if(data == 1) nomeGrupo = 'Essencial'; 
                              if(data == 2) nomeGrupo = 'Importante'; 
                              if(data == 3) nomeGrupo = 'Supérfluo'; 
                              var grupo = "<a class='hightlight' href='../grupos/'>" + nomeGrupo +
                              " <i class='fa fa-external-link font-size-10' aria-hidden='true'></i></a>";
                              return grupo;
    

    Solved here, thanks!

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This discussion has been closed.