You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@usingSystem.ComponentModel
<Table DataSource="@data" Bordered><PropertyColumn Property="c=>c.Name"ColSpan="@GetColSpan(context.Key,"name")"></PropertyColumn><PropertyColumn Property="c=>c.Age"ColSpan="@GetColSpan(context.Key)"></PropertyColumn><PropertyColumn Property="c=>c.Tel"Title="Home phone"HeaderColSpan="2"RowSpan="@GetRowSpan(context.Key)"ColSpan="@GetColSpan(context.Key)"></PropertyColumn><PropertyColumn Property="c=>c.Phone"HeaderColSpan="0"ColSpan="@GetColSpan(context.Key)"></PropertyColumn><PropertyColumn Property="c=>c.Address"ColSpan="@GetColSpan(context.Key)"></PropertyColumn></Table>
@code {
Data[] data ={new Data(){Key="1",Name="John Brown",Age=32,Tel="0571-22098909",Phone="18889898989",Address="New York No. 1 Lake Park"},new Data(){Key="2",Name="Jim Green",Tel="0571-22098333",Phone="18889898888",Age=42,Address="London No. 1 Lake Park"},new Data(){Key="3",Name="Joe Black",Age=32,Tel="0575-22098909",Phone="18900010002",Address="Sidney No. 1 Lake Park"},new Data(){Key="4",Name="Jim Red",Age=18,Tel="0575-22098909",Phone="18900010002",Address="London No. 2 Lake Park"},new Data(){Key="5",Name="Jake White",Age=18,Tel="0575-22098909",Phone="18900010002",Address="Dublin No. 2 Lake Park"}};publicclassData{publicstringKey{get;set;}publicstringName{get;set;}publicintAge{get;set;}publicstringTel{get;set;}publicstringPhone{get;set;}publicstringAddress{get;set;}}privateintGetRowSpan(stringkey){// there,first render the key when be nullif(key=="3")return2;elseif(key=="4")return0;elsereturn1;}privateintGetColSpan(stringkey,stringcolumnTitle=""){// there,first render the key when be nullif(key=="5")if(columnTitle=="name")return5;elsereturn0;elsereturn1;}}
ElderJames
changed the title
Table组件合并单元格,表格初始化的时候会先调用一次RowSpan,ColSpan.即使我的DataSource是空的
The Table component merges cells, and when the table is initialized, it will call RowSpan and ColSpan once first, even if my DataSource is empty
Apr 24, 2024
Describe the bug
Table 组件有RowSpan,ColSpan属性时,会在初始化的时候调用RowSpan,ColSpan(应该不是这么设计的吧?).如果不返回1,会导致后续数据单元格合并计算错误.
Steps to reproduce (please include code)
GetRowSpan先被调用时,key是null值.
官网的例子刚好返回了1,避过了这个问题.
Exceptions (if any)
后续表格渲染不正确
The text was updated successfully, but these errors were encountered: