question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tdClass function does not receive the value of the formatter function in the table

See original GitHub issue

Describe the bug

I have a formatting function defined in a table column but when I create the tdClass function it does not receive that value, if not the original one

Steps to reproduce the bug

// Virtual Column
{
  key: 'diff',
  label: 'Diff',
  class: 'text-right',
  formatter: (_, __, item) => {
    if (!item.duration || !item.estimatedDuration) return

    const operation = item.duration - item.estimatedDuration
    const decimals = 4

    // Round Decimals
    return (
      Math.round(operation * Math.pow(10, decimals)) /
      Math.pow(10, decimals)
    )
  },
  tdClass: (value) => {
    if (Math.sign(value) === 1 && value >= 1) return 'table-danger'
    if (Math.sign(value) === 1 && value < 1) return 'table-warning'

    return 'table-success'
  },
},

Expected behavior

In my opinion, the tdClass function should return the value of the formatter function and not force me to write the contents of the formatter function again

Versions

Libraries:

  • BootstrapVue: 2.15.0
  • Bootstrap: 4.5.0
  • Nuxt: 2.12.2

Environment:

  • Device: Mac
  • OS: macOS Mojave
  • Browser: Chrome
  • Version: 83.0.4103.97

Demo link

Not applicable

Additional context

Add any other context about the bug here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
frbucetacommented, Jun 16, 2020

You could move your formatter to methods. This will allow you to use it as your formatter, and use it inside tdClass without having to write the function twice.

https://codepen.io/Hiws/pen/ExPKyjz

It works, even there I will leave this open. Thank you

0reactions
stale[bot]commented, Oct 3, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstrap-vue table td element styling - Stack Overflow
You can set the tdClass property inside of your field object. But tdClass just accepts a string or an array, not an object....
Read more >
Table | Components - BootstrapVue
items is the table data in array format, where each record (row) data are keyed ... The function will be called as tdClass(value,...
Read more >
border-top-style - CSS: Cascading Style Sheets | MDN
This is a box with a border around it. ... Note: The specification doesn't define how borders of different styles connect in the...
Read more >
Custom JQuery code targeting elements of the table is not ...
I am trying to achieve something. I have a row with two columns. In the left column, I have the tablesome table and...
Read more >
How to index only part of a html log file? - Splunk Community
Section 4: Actual log file, in a table format. DB Dateand Time ALM Node Date and Time Thread Request Type Login IP Level...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found