masastack / MASA.Blazor

Blazor UI component library based on Material Design. Support Blazor Server, Blazor WebAssembly and MAUI Blazor.
https://docs.masastack.com/blazor/getting-started/installation
MIT License
1.12k stars 151 forks source link

希望表格支持长字符串省略显示 #905

Closed HongChenLuYuan closed 1 year ago

HongChenLuYuan commented 1 year ago

如题,希望表格支持长字符串省略显示。

doddgu commented 1 year ago

表格默认不会支持自动文本截断。但你可以通过控制列的class来达到相同的效果。文档在:https://blazor.masastack.com/stylesandanimations/text-and-typography

HongChenLuYuan commented 1 year ago

明白了,感谢指导。

doddgu commented 1 year ago

如果满意可以给个star支持一下,谢谢

HongChenLuYuan commented 1 year ago

没用,表格列使用截断css class根本不生效

------------------ 原始邮件 ------------------ 发件人: "BlazorComponent/MASA.Blazor" @.>; 发送时间: 2023年1月11日(星期三) 上午9:27 @.>; @.>;"State @.>; 主题: Re: [BlazorComponent/MASA.Blazor] 希望表格支持长字符串省略显示 (Issue #905)

如果满意可以给个star支持一下,谢谢

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

doddgu commented 1 year ago

我写了个伪代码,你看一下。目前 context.Header 还没有把属性都传给DataTable,有点小问题。通过加一个 div 的 文本阶段和限制宽度就可以解决。

        <ItemColContent>
            @if (context.Header.Value == nameof(WeatherForecast.Date))
            {
                @context.Item.Date.ToShortDateString()
            }
            else if (context.Header.Value == nameof(WeatherForecast.Summary))
            {
                <div class="text-truncate" style="width: 200px;">@context.Value</div>
            }
            else
            {
                @context.Value
            }
        </ItemColContent>
HongChenLuYuan commented 1 year ago

好的用div生效了,我昨天用的span标签,当时是没生效,还有这样做了后表格组件指定width属性的就算是废了。 谢谢指导。

------------------ 原始邮件 ------------------ 发件人: "BlazorComponent/MASA.Blazor" @.>; 发送时间: 2023年1月11日(星期三) 上午10:55 @.>; @.>;"State @.>; 主题: Re: [BlazorComponent/MASA.Blazor] 希望表格支持长字符串省略显示 (Issue #905)

我写了个伪代码,你看一下。目前 context.Header 还没有把属性都传给DataTable,有点小问题。通过加一个 div 的 文本阶段和限制宽度就可以解决。 <ItemColContent> @if (context.Header.Value == nameof(WeatherForecast.Date)) { @context.Item.Date.ToShortDateString() } else if (context.Header.Value == nameof(WeatherForecast.Summary)) { <div class="text-truncate" style="width: @.***</div> } else { @context.Value } </ItemColContent>

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

doddgu commented 1 year ago

DataTable 上次重构改出了点小问题,1.0会抽时间修复一下。到时候可以不需要自己再套Div了,通过Header设置CellClass + Width即可。 我先关闭issue了,有问题可以随时reopen。