"Duplicate row" feature:

* Copy NULL flag from source row, not just the text "(NULL)". Fixes issue #1607
* Do not overtake values from an auto increment column. Fixes issue #1608
This commit is contained in:
Ansgar Becker
2010-01-16 17:46:11 +00:00
parent 8b9c7da6fb
commit c2857f438a

View File

@ -6932,6 +6932,7 @@ procedure TMainForm.DataGridInsertRow(CopyValuesFromNode: PVirtualNode);
var var
i, j: Integer; i, j: Integer;
Val: String; Val: String;
OldRow, NewRow: TGridRow;
begin begin
// Scroll to the bottom to ensure we append the new row at the very last DataGridResult chunk // Scroll to the bottom to ensure we append the new row at the very last DataGridResult chunk
DataGrid.FocusedNode := DataGrid.GetLast; DataGrid.FocusedNode := DataGrid.GetLast;
@ -6947,10 +6948,16 @@ begin
end; end;
DataGrid.FocusedNode := DataGrid.AddChild(nil); DataGrid.FocusedNode := DataGrid.AddChild(nil);
if Assigned(CopyValuesFromNode) then begin if Assigned(CopyValuesFromNode) then begin
OldRow := DataGridResult.Rows[CopyValuesFromNode.Index];
NewRow := DataGridResult.Rows[DataGrid.FocusedNode.Index];
for j:=0 to DataGrid.Header.Columns.Count-1 do begin for j:=0 to DataGrid.Header.Columns.Count-1 do begin
Val := DataGrid.Text[CopyValuesFromNode, j]; if not (coVisible in DataGrid.Header.Columns[j].Options) then
if (coVisible in DataGrid.Header.Columns[j].Options) and (Val <> '') then continue; // Ignore invisible key column
DataGrid.Text[DataGrid.FocusedNode, j] := Val; if SelectedTableColumns[j].DefaultType = cdtAutoInc then
continue; // Empty value for auto-increment column
NewRow.Cells[j].NewText := OldRow.Cells[j].Text;
NewRow.Cells[j].NewIsNull := OldRow.Cells[j].IsNull;
NewRow.Cells[j].Modified := True;
end; end;
end; end;
DataGrid.ClearSelection; DataGrid.ClearSelection;