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

176
Visualizações
How to make image with dynamic source (JS)?

I want to add a logo for each game in my table, it has to be above the title of first column. The links to the demo logo are in "L" column of the source table, this column also defined:

L: 'Logo',

So I need to use this Logo variable and turn it into image.

The string below is responsible for the title column and I need to modify it some way:

{ field: 'Title', sortable: true, minWidth: 180, cellClass: 'title-column'}

I tried something like, but it doesn't work:

    { field: 'Title', sortable: true, minWidth: 180, cellClass: 'title-column', cellRenderer: function(params) {
  const LogoLink = params.data.Link;

  let content = "";

  if (LogoLink) {
    content += document.getElementById('make-image').src=LogoLink;
  }

Also, the filter of the title column should not be broken (in may perceive names of image links as content, this shouldn't happen).

Maybe it should be something like this:

    { field: 'Title', sortable: true, minWidth: 180, cellClass: 'title-column', cellRenderer: function(params) {
  const LogoLink = params.data.Logo;
content = LogoLink + params.data.Title;
  return content; }},

but I don't know how to wrap LogoLink to make it an HTML image.

Full working code: https://plnkr.co/plunk/w9bgMFlTF8JPK4t9

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

0

Hmm, it seems that this solution works:

{ field: 'Title', sortable: true, minWidth: 100, cellClass: 'title-column', cellRenderer: function(params) {
  const LogoLink = params.data.Logo;
  LogoLink.id = 'image';
content =  '<img src=' + LogoLink + ' class="logo-image">' + params.data.Title;
  return content; }},

Correct me please, if there are any mistakes/bad coding.

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