Commit 31433402 authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed bug with calculating table grid.

parent 9bc428f9
...@@ -275,57 +275,70 @@ CTable.prototype.private_RecalculateGrid = function() ...@@ -275,57 +275,70 @@ CTable.prototype.private_RecalculateGrid = function()
TableW = MinWidth; TableW = MinWidth;
} }
var CurGridCol = 0; var CurGridCol = 0;
for ( var Index = 0; Index < this.Content.length; Index++ ) for (var Index = 0; Index < this.Content.length; Index++)
{ {
var Row = this.Content[Index]; var Row = this.Content[Index];
Row.Set_Index( Index ); Row.Set_Index(Index);
// Смотрим на ширину пропущенных колонок сетки в начале строки // Смотрим на ширину пропущенных колонок сетки в начале строки
var BeforeInfo = Row.Get_Before(); var BeforeInfo = Row.Get_Before();
CurGridCol = BeforeInfo.GridBefore; CurGridCol = BeforeInfo.GridBefore;
if ( CurGridCol > 0 && SumGrid[CurGridCol - 1] < BeforeInfo.WBefore.W ) if (CurGridCol > 0 && SumGrid[CurGridCol - 1] < BeforeInfo.WBefore.W)
SumGrid[CurGridCol - 1] = BeforeInfo.WBefore.W; {
var nTempDiff = BeforeInfo.WBefore.W - SumGrid[CurGridCol - 1];
var CellsCount = Row.Get_CellsCount(); for (var nTempIndex = CurGridCol - 1; nTempIndex < SumGrid.length; ++nTempIndex)
for ( var CellIndex = 0; CellIndex < CellsCount; CellIndex++ ) SumGrid[nTempIndex] += nTempDiff;
{ }
var Cell = Row.Get_Cell( CellIndex );
Cell.Set_Index( CellIndex ); var CellsCount = Row.Get_CellsCount();
var CellW = Cell.Get_W(); for (var CellIndex = 0; CellIndex < CellsCount; CellIndex++)
var GridSpan = Cell.Get_GridSpan(); {
var Cell = Row.Get_Cell(CellIndex);
if ( CurGridCol + GridSpan - 1 > SumGrid.length ) Cell.Set_Index(CellIndex);
{ var CellW = Cell.Get_W();
for ( var AddIndex = SumGrid.length; AddIndex <= CurGridCol + GridSpan - 1; AddIndex++ ) var GridSpan = Cell.Get_GridSpan();
SumGrid[AddIndex] = SumGrid[AddIndex - 1] + 20; // Добавляем столбик шириной в 2 см
} if (CurGridCol + GridSpan - 1 > SumGrid.length)
{
if (tblwidth_Auto !== CellW.Type && tblwidth_Nil !== CellW.Type) for (var AddIndex = SumGrid.length; AddIndex <= CurGridCol + GridSpan - 1; AddIndex++)
{ SumGrid[AddIndex] = SumGrid[AddIndex - 1] + 20; // Добавляем столбик шириной в 2 см
var CellWidth = 0; }
if (tblwidth_Pct === CellW.Type)
CellWidth = PctWidth * CellW.W / 100; if (tblwidth_Auto !== CellW.Type && tblwidth_Nil !== CellW.Type)
else {
CellWidth = CellW.W; var CellWidth = 0;
if (tblwidth_Pct === CellW.Type)
if (CellWidth + SumGrid[CurGridCol - 1] > SumGrid[CurGridCol + GridSpan - 1]) CellWidth = PctWidth * CellW.W / 100;
SumGrid[CurGridCol + GridSpan - 1] = CellWidth + SumGrid[CurGridCol - 1]; else
} CellWidth = CellW.W;
CurGridCol += GridSpan; if (CellWidth + SumGrid[CurGridCol - 1] > SumGrid[CurGridCol + GridSpan - 1])
} {
var nTempDiff = CellWidth + SumGrid[CurGridCol - 1] - SumGrid[CurGridCol + GridSpan - 1];
// Смотрим на ширину пропущенных колонок сетки в конце строки for (var nTempIndex = CurGridCol + GridSpan - 1; nTempIndex < SumGrid.length; ++nTempIndex)
var AfterInfo = Row.Get_After(); SumGrid[nTempIndex] += nTempDiff;
if ( CurGridCol + AfterInfo.GridAfter - 1 > SumGrid.length ) }
{ }
for ( var AddIndex = SumGrid.length; AddIndex <= CurGridCol + AfterInfo.GridAfter - 1; AddIndex++ )
SumGrid[AddIndex] = SumGrid[AddIndex - 1] + 20; // Добавляем столбик шириной в 2 см CurGridCol += GridSpan;
} }
if ( SumGrid[CurGridCol + AfterInfo.GridAfter - 1] < AfterInfo.WAfter + SumGrid[CurGridCol - 1] )
SumGrid[CurGridCol + AfterInfo.GridAfter - 1] = AfterInfo.WAfter + SumGrid[CurGridCol - 1]; // Смотрим на ширину пропущенных колонок сетки в конце строки
} var AfterInfo = Row.Get_After();
if (CurGridCol + AfterInfo.GridAfter - 1 > SumGrid.length)
{
for (var AddIndex = SumGrid.length; AddIndex <= CurGridCol + AfterInfo.GridAfter - 1; AddIndex++)
SumGrid[AddIndex] = SumGrid[AddIndex - 1] + 20; // Добавляем столбик шириной в 2 см
}
if (SumGrid[CurGridCol + AfterInfo.GridAfter - 1] < AfterInfo.WAfter + SumGrid[CurGridCol - 1])
{
var nTempDiff = AfterInfo.WAfter + SumGrid[CurGridCol - 1] - SumGrid[CurGridCol + AfterInfo.GridAfter - 1];
for (var nTempIndex = CurGridCol + AfterInfo.GridAfter - 1; nTempIndex < SumGrid.length; ++nTempIndex)
SumGrid[nTempIndex] += nTempDiff;
}
}
// TODO: разобраться с минимальной шириной таблицы и ячеек // TODO: разобраться с минимальной шириной таблицы и ячеек
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment