誰もが知っているように、これは可能です。私はjqueryを使用してソリューションを終了しましたが、それはかなりうまく機能します。各テーブルに特定のcssクラスを割り当て、それを使用して、サイズを変更する必要があるテーブルを識別しました(各テーブルは一意である必要があるため、IDを使用しないでください)。それは4つの主要なブラウザで動作します。IE7の場合、これが機能するように、空のセルにスペースを追加してください。これがJavascriptです:
function ResizeTableRows() {
// select tables by css class name using jquery
var tables = $('.myCssClassName');
// all tables should have the save number of rows, so just use the first one
var totalRows = tables[0].rows.length;
for (var rowNumber = 0; rowNumber < totalRows; rowNumber++) {
var maxRowHeight = GetMaxRowHeight(tables, rowNumber);
for (var i = 0; i < tables.length; i++) {
if (maxRowHeight > 0) {
tables[i].rows[rowNumber].height = maxRowHeight;
SetCellHeight(tables[i].rows[rowNumber].cells, maxRowHeight);
}
}
}
}
function GetMaxRowHeight(tables, rowNumber) {
var maxRowHeight = 0;
for (var i = 0; i < tables.length; i++) {
var row1 = tables[i].rows[rowNumber];
var cell1 = row1.cells[0];
var rowHeight = row1.clientHeight;
if (rowHeight <= 0) {
rowHeight = row1.height;
}
if (rowHeight <= 0) {
rowHeight = cell1.clientHeight;
}
if (rowHeight > maxRowHeight) {
maxRowHeight = rowHeight;
}
}
return maxRowHeight;
}
function SetCellHeight(cells, maxRowHeight) {
for (var i = 0; i < cells.length; i++) {
cells[i].height = maxRowHeight;
}
}
プロセスを開始するためのコードは次のとおりです。Webコントロールではなく、メインページに追加します(.netを使用している場合)
<script type="text/javascript">
// runs automatically after this page has been loaded and rendered
$(document).ready(function() {
ResizeTableRows();
});
</script>