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
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletionspackages/coreui-vue/src/components/table/CTable.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -238,7 +238,7 @@ const CTable = defineComponent({
default:()=>[
columnNames.value&&
columnNames.value.map(
(colName:string)=>
(colName:string,idx:number)=>
item[colName]!==undefined&&
h(
CTableDataCell,
Expand All@@ -251,7 +251,14 @@ const CTable = defineComponent({
}),
},
{
default:()=>item[colName],
default:()=>{
constcolumn=props.columns![idx];
constvalue=item[colName];

returntypeofcolumn==="object"&&column.formatter
?column.formatter(value)
:value;
Comment on lines +255 to +260
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.

}
},
),
),
Expand Down
3 changes: 2 additions & 1 deletionpackages/coreui-vue/src/components/table/types.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,8 @@ export type Column = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_style?: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_props?: any
_props?: any,
formatter?: (value: unknown) => string
}

export type FooterItem = {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp