Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Modify a not visible column's fieldvalue in a TLMDDBGrid

Hello,

I need to modify the
value of a field linked to a not visible column of a LMDDBGrid, but
this operation is not possible because of the Assert in the 
following function:


function
TLMDCustomGrid.DataColToGridCol(ACol: Integer): Integer;

var

i: Integer;

begin

  Assert(IsColVisible(ACol));

  Result := 0;

  for i := 0 to ACol
- 1 do

  if
Columns[i].Visible then

    Inc(Result);

  if opShowIndicator
in Options then

    Result := Result
+ 1

  else

    Result :=
Result;

end;




Is it possible to find a solution?

Thanks,

Cristina

Comments

  • 3 Comments sorted by Votes Date Added
  • Non-visible column have no grid coordinate, because it not shown in the grid. Why you can't just modify data-set field directly, without using grid functionality at all?
  • I'm actually changing the dataset field directly. You can try this: new project, new form, put a TFDMemTable, add some fields, set one to Visible = False, add datasource and TLMDDBGrid, connect all together, put a button where you'll add a record to the memtable and write field values, as soon as you'll write the invisible field the assertion failure will arise.

    I'm now using the new LMDGrid.pas unit with the opShowRowChecks fix, the assertion is now on line 6946.

    BTW, another assertion failure arises on line 9388 if I'll try to "add all columns from data source fields" in the Columns editor. This is the function:

    procedure TInternalStore.ColumnAdded(ACol: Integer);
    var
      i:   Integer;
      row: TRow;
    begin
      Assert(ACol = FColCount); // Only appending as last
                                // column is implemented.

      for i := 0 to FRows.Count - 1 do
      begin
        if FRows[i] <> nil then
        begin
          row := TRow(FRows[i]);
          SetLength( row.Values, FColCount + 1 );
          row.Values[ FColCount ] := Null;
        end;
      end;

      Inc(FColCount);
      SetLength(FColIndexes, FColCount);
      FColIndexes[FColCount - 1] := FColCount - 1;
    end;

    Thank you.
  • new project, new form, put a TFDMemTable, add some fields, set one to Visible = False...

    Fixed.

    BTW, another assertion failure arises on line 9388 if I'll try to "add all columns from data source fields" in the Columns editor...

    Fixed.

    I'm now using the new LMDGrid.pas unit with the opShowRowChecks fix, the assertion is now on line 6946.

    Probably, fixed too. Please check.

Sign In or Register to comment.