Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added formatter to column object#303

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
gfoidl wants to merge1 commit intocoreui:main
base:main
Choose a base branch
Loading
fromgfoidl:table-formatter

Conversation

gfoidl
Copy link
Contributor

The table data items are displayed by simpletoString (internally).

This PR adds the optional propertyformatter, so you can do something like

functionformatTimeStamp(value:Date):string{returnvalue.toLocaleString();}functionformatNumber(value:number):string{returnvalue.toLocaleString(undefined,{maximumFractionDigits:2,minimumFractionDigits:1});}constcolumns=[{key:"timeStampUtc",label:"Timestamp",formatter:formatTimeStamp},{key:"mean",label:"Mean",formatter:formatNumber},{key:"median",label:"Median",formatter:formatNumber},{key:"sigma",label:"Sigma",formatter:formatNumber}];

in order to specify aformatter, that will convert each item's property according the given formatter-function.

Note

It's optional to specify theformatter

Comment on lines +255 to +260
const column = props.columns![idx];
const value = item[colName];

return typeof column === "object" && column.formatter
? column.formatter(value)
: value;
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I know that there may be better ways, but that would need quite a bit of code-change.
This was tested with a rather big table, and no perf-problems did occur, so I'm fine with this approach.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@gfoidl

[8]ページ先頭

©2009-2025 Movatter.jp