TableHeaderRow类的意义是什么

时间:2022-09-06 22:42:28

I've just converted some code from using HtmlTable controls to the web based Table controls and I found that in additional to the TableRow class there is also TableHeaderRow. I foolishly made the assumption based on some half read comments on here that if a row was one of these that it would be put in a thead element in the outputted HTML. It wasn't.

我刚刚将一些代码从使用HtmlTable控件转换为基于web的表控件,我发现在TableRow类中还有一个TableHeaderRow。我愚蠢地假设,如果一行是其中之一,那么它将被放在输出的HTML中的thead元素中。它不是。

When this didn't work I looked close and noticed that TableHeaderRow seems to have no actual code on it and that the TableSection property of TableRow doesn't care if its a TableHeaderRow or not.

当它不起作用时,我仔细观察,发现TableHeaderRow似乎没有实际的代码,而TableRow的汤匙属性并不关心它是否是一个TableHeaderRow。

So what is the point of this type? It seems that in practice it is exactly identical to the TableRow class and you still have to set the TableSection property on it to tell it that its a thead row.

那么这种类型的意义是什么呢?实际上,在实践中它和TableRow类完全一样,你仍然需要设置它的大汤匙属性来告诉它它是一个thead行。

Is there a good use case scenario for this? I certainly can't think of one...

这有一个好的用例场景吗?我当然想不出一个……

Edit for clatification

编辑对clatification

In my investigations I have used Refactor to look at the code involved. This is how I determined that TableHeaderRow seems to derive from TableRow but not actually implement anythign new.

在我的调查中,我使用了Refactor来查看涉及的代码。这就是我如何确定TableHeaderRow似乎是从TableRow派生出来的,但实际上并没有实现任何新的设计。

In the rendering for Table when determining whether to output a thead or not it seems to look purely at the TableSection property. It doesn't care what the actual type of the row is and I can't find a single line of code anywhere that I've looked that would behave differently purely from the type of the row being different.

在表的呈现中,当决定是否输出一个thead时,它看起来纯粹是看表属性。它不关心行的实际类型,我在任何地方都找不到一行代码,它们的行为与行类型不同。

I'm looking for an actual practical example of how it differs. While I appreciate doc references they don't actually seem to match with the code I'm looking at.

我正在寻找一个实际的例子来说明它是如何不同的。虽然我很欣赏doc引用,但它们似乎与我正在查看的代码并不匹配。

2 个解决方案

#1


4  

I wondered the same thing. When I saw the page Creating ASP.NET table header row I realized that I was not setting the TableSection property as I should:

我也在想同样的事情。当我看到创建ASP的页面时。NET表格标题行我意识到我没有设置表格属性,因为我应该:

hRow.TableSection = Web.UI.WebControls.TableRowSection.TableHeader

It made the <thead> element to apear in the output html.

它将元素添加到输出html中。

#2


1  

According to this MSDN entry:

根据这个MSDN条目:

This class supports displaying tables on devices with a limited screen size. On these devices, a table with many columns and rows must be rendered across multiple pages. Adding a TableHeaderRow to a Table control allows you to specify a heading row that is rendered as the first row on each page that displays a view of the table.

该类支持在屏幕大小有限的设备上显示表。在这些设备上,必须跨多个页面呈现具有多个列和行的表。将一个TableHeaderRow添加到一个表控件中,可以指定一个标题行,它被呈现为每个页面上显示该表视图的第一行。

I would infer from this that TableRow doesn't expose this kind of support.

我由此推断,TableRow并没有公开这种支持。

#1


4  

I wondered the same thing. When I saw the page Creating ASP.NET table header row I realized that I was not setting the TableSection property as I should:

我也在想同样的事情。当我看到创建ASP的页面时。NET表格标题行我意识到我没有设置表格属性,因为我应该:

hRow.TableSection = Web.UI.WebControls.TableRowSection.TableHeader

It made the <thead> element to apear in the output html.

它将元素添加到输出html中。

#2


1  

According to this MSDN entry:

根据这个MSDN条目:

This class supports displaying tables on devices with a limited screen size. On these devices, a table with many columns and rows must be rendered across multiple pages. Adding a TableHeaderRow to a Table control allows you to specify a heading row that is rendered as the first row on each page that displays a view of the table.

该类支持在屏幕大小有限的设备上显示表。在这些设备上,必须跨多个页面呈现具有多个列和行的表。将一个TableHeaderRow添加到一个表控件中,可以指定一个标题行,它被呈现为每个页面上显示该表视图的第一行。

I would infer from this that TableRow doesn't expose this kind of support.

我由此推断,TableRow并没有公开这种支持。