HOW TO HIGHLIGHT A RESULT ACCORDING TO CONDITIONAL?

HOW TO HIGHLIGHT A RESULT ACCORDING TO CONDITIONAL?

Bebe ÓleoBebe Óleo Posts: 4Questions: 1Answers: 0

How could I score a result without datatable? If a search would return a specific result in a row in the table, could this be in a different color or with the data in bold? In other words, highlight when specific data in one or more columns****

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923
    edited December 2020

    Not sure I understand your question. Sounds like you want to highlight a cell or row based on row data. You can use columns.createCell or createdRow for this. If this doesn't help maybe you can build a simple example of what you have with details of what you want to do.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • Bebe ÓleoBebe Óleo Posts: 4Questions: 1Answers: 0

    EXAMPLE: I would like the conditional 'Ana Diva' and the date '09/12/2020' to be marked when a search was made.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    I'm not following, sorry. All those records in your table match that condition - as the filter has been applied. What makes the highlighted rows special?

    Colin

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    One option might be to use rowCallback. In the function get the value of the search input and if it matches the data then highlight the row. See this example. The example uses createdRow but you will want to use rowCallback since rowCallback runs each time the table is drawn.

    You will need to create your own search input if you don't actually want to filter the table rows.

    Kevin

  • Bebe ÓleoBebe Óleo Posts: 4Questions: 1Answers: 0

    Pensei em criar uma tabela no banco de dados com os registros que ficariam em vermelho, por exemplo

    data medico
    2020-12-09 Ana Diva
    xxxx-xx-xx x

    as linhas que tivesse essa condição ficariam marcadas.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    Gotcha, Kevin's post is the way to go then,

    Colin

  • Bebe ÓleoBebe Óleo Posts: 4Questions: 1Answers: 0

    Thanks Colin, thanks, Kevin

    I m try this tomorowwww

    ;)

This discussion has been closed.