Skip to content

feat(table): 添加 DataTable 的数字格式化支持 #3215

@densen2014

Description

@densen2014

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

No response

Describe the solution you'd like

目前我用检测是数值列就直接设置2位小数和居中对齐,不知道老张有啥好想法

DataTableDynamicContext = new DataTableDynamicContext(res, (Action<DataTableDynamicContext, ITableColumn>?) NumberFormatter());


    public static Action<DataTableDynamicContext, ITableColumn> NumberFormatter()
    {
        return (context, col) =>
        {
            // 设置 数字列
            if (col.PropertyType.IsNumberType())
            {
                col.FormatString = col.PropertyType == typeof(int) ? "" : "N2";
                col.Align = Alignment.Center;
            }
            if (col.PropertyType == typeof(DateTime))
            {
                col.FormatString = "yyyy-MM-dd";
            }
        };
    }

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions