Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I set specific format for Columns ? #15

Open
rczupa opened this issue Mar 25, 2020 · 5 comments
Open

How can I set specific format for Columns ? #15

rczupa opened this issue Mar 25, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@rczupa
Copy link

rczupa commented Mar 25, 2020

Hi how are you ?

I need format the columns that have numeric values, including monetary symbol. But, I can have in same pivot table, different columns, that must have different formats, one can be money, other can be percent and etc.

I believe, using "{{ value.toLocaleString }}" I can do that, but, I dont know how can I check what field are to apply the specific format.

Can you help-me ?

Thanks a lot

@antoinematyja
Copy link
Contributor

antoinematyja commented Mar 27, 2020

Hi :) I have the same issue and it is indeed very tricky. (the whole library is tricky but this one in particuliar)

It is currently not possible.

To solve this problem I introduced additional parameters to the value slot: col and row. They allow you to get the values of the columns/rows for the current cell.

The idea is that if you have a row or column that should generate a row or column formatted as a currency only for a specific value, you will want to provide a value slot like:

<template v-slot:value="{ value, col, row }">
  <template v-if="checkIfCurrency(col, row)">{{ value | currency }}</template>
  <template v-else>{{ value }}</template>
</template>

But the checkIfCurrency function doesn't know the order of the rows/columns, so it doesn't know which part of the col/row arguments corresponds to the column that could have a specific currency value.

I think I need to provide a way to get the row/column fields selected by the user, so that this function can check the right value.

@antoinematyja antoinematyja added the enhancement New feature or request label Mar 27, 2020
@rczupa
Copy link
Author

rczupa commented Mar 27, 2020

Hi antoinematyja ,

In my case, if I try use a function similar to "checkIfCurrency, the parameters col and row, are undefined.

I dont know wy.

@antoinematyja
Copy link
Contributor

You are probably using an old version, these parameters were added in v0.2.1. Can you tell me what version you are using ?

Also I just released v1.0.0 which changed a little bit the Pivot component API, now the row/col provide arrays instead of objects.

@rczupa
Copy link
Author

rczupa commented Mar 27, 2020

Its true, Im using the version 0.0.1, because I created my project based on the project of "mitsakosgr" , he create a solution that allow I can use different algoritms by Colfield.

I will try merge the solutions, and after solve this problem.

In my local solution, I implemented grand total by grouping, after merge, I share with you.

Thanks a lot

@rczupa
Copy link
Author

rczupa commented Mar 30, 2020

antoinematyja how are you ?

i got it to format the columns in another way. I created an hash that stores the columns key that have slotName, like implemented in rowFields, and I use a similar method like "value" to retrieve the slotName of column. In this way, I need when I use the pivotTable component, list one slot per column field.

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants