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

225
Visualizações
How to apply conditional checking on input columns in a JavaScript Datatable

Below shows one of a column in my javaScript Datatable:

       {
            "className": 'child_grid',
            "data": function (data) {
                return '<input disabled id="comment" data - val="true" type = "text" value = "' + data.LookupComment + ' != null ? ' + data.LookupComment + ' : """ style = "height: 2rem !important;" >';
            }                    
        },

Here I have check for null value in the input field. If it is null, want to show blank. For that I have applied condition in the value="" property. But instead of checking condition, it is printing whole conditions in the UI.

If I directly use the value variable in the input value property, it displays null in case of null value as given below.

enter image description here

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

0

What about creating the value prior to the return?
Something like this..

"data": function(data) {
  const value = data.LookupComment !== null ? data.LookupComment : '';
  return '<input disabled id="comment" data-val="true" type="text" value="value" style = "height: 2rem !important;" >'; 
}                            
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