komarovalexander / ka-table

Lightweight MIT React Table component with Sorting, Filtering, Grouping, Virtualization, Editing and many more
http://ka-table.com
MIT License
769 stars 56 forks source link

Formatted value #340

Closed zatopek-firstis closed 10 months ago

zatopek-firstis commented 1 year ago

Hi, I got an issue regarding formatting.

While processing in your core, all values get formatted by format function (tableState.format) and returns correct value. But then I have no means to access that formatted value in childComponents.cell or childComponents.cellText and I have to format it again to get the right display value. Can you please add formattedValue to cellText and cell?

komarovalexander commented 10 months ago

Hi @zatopek-firstis format is used by CellText, and formatted value is generated inside that component. You are doing it right way "I have to format it again to get the right display value" because you override cellText behavior and format is not called anymore by Table.

komarovalexander commented 2 weeks ago

you can access format function from props, example:

              cellText: {
                    content: (props) => {
                        switch (props.column.key) {
                            case 'date':
                                return (
                                    <a
                                        href={link.tasks.detail({ date: props.value })}
                                    >{props.format?.(props)}</a>
                                );
                        }
                    },
                }