TMSFMXLiveGrid issue when the app window is maximized

Hello,
We found the following issue when the app window containing TMSFMXLiveGrid is maximized. If the LiveGrd's corresponding query returns more records than can be shown on screen at the same time (for example, the query returns 40 records but there are only 15 of them shown at the same time) and we try to print all the contents of the grid (all 40 records), only the visible rows of the grid get printed (15 rows), and then the first row gets repeatedly printed (the first row of the 15 is printed 25 times, until we reach 40). This problem disappears when the app window is not maximized (all rows are then printed correctly). Can this be fixed, or is there a workaround or an update we need to install? Thanks.

We'll look into this issue as soon as possible.

The behavior is by design, as the grid does not load all data. Please use LoadAllDataAndDisconnect before exporting/printing.

Hi Pieter,
I have tried the proposed solution. I added the statement:
liveGridName.LoadAllDataAndDisconnect;
right before the rest of my printing code. The issue described above is now happening not only when the app is maximized, but also when it's not maximized. Did I do something incorrectly? Thanks!

Hi,

Did you use a BeginUpdate & EndUpdate statement as well around the code? The LoadAllDataAndDisconnect should load all data in the grid, which is required for printing.

Hello,

Yes, I tried both with and without BeginUpdate and EndUpdate. This is how I did it:
myGrid.LoadAllDataAndDisconnect;
myGrid.BeginUpdate;
.....
myGrid.EndUpdate;

Was this the correct way to do it? The issue still persists. Please let me know if I am missing anything. Thanks!

Can you put together a small sample (perhaps based on a tclientdataset) in order to reproduce the issue?

I will put something together and get back to you. Thanks!

Hello,

Sorry it took so long. I was able to reproduce the issue in a small separate app, which is attached. Initially, when I placed the livegrid directly on Form1, hooked it to my data source (SQLite database testDB.db included with the zip file) and added the Into File button to export contents of the database into the file (which is located in Win32/Debug subfolder of the attachment and is called PrintFile.txt), contents of my liveGrid would export to the file normally, no issue indicated. Then, when I added a TPanel object, placed my grid on it (like it is done in our original app), and changed properties Align, Anchors, and Selection Mode of the grid to match the original app, I was able to reproduce the repetitive output of the first cell, as described in the issue. When I moved the grid back off the panel and changed the features back to their original state, the repetitive output issue did not go away. Please let me know your thoughts on this. The properties I have changed were as follows:
Align: originally was None, then Client, then back to None
Anchors: originally akLeft and akTop, changed to akLeft, akTop, akRight, akBottom, then back to original
SelectionMode: was smSingleCell, changed to smDisjunctRow, then back to original.
It almost feels like something got thrown off after the liveGrid's properties were modified, but never got back to the original state. Thanks!
TestProject.zip (1.2 MB)

Hello,
In addition to the information above, I was just informed by the users that the issue now happens both in maximized and non-maximized window. Please advise. Thanks!

I already explained that the grid does not load all data, so only the visible row data is available. To export data, you can use the following code snippet which prepares the grid for exporting data that is not visible yet.

procedure TForm1.btnIntoFileClick(Sender: TObject);
var
  printFile: TextFile;
  SavePlace: TBookmark;
  holdItem: String;
  i: Integer;
begin
  if (liveGridTest.RowCount <= 1) then
    ShowMessage('The grid is empty')
  else
  begin
    SavePlace := BindSourceDB1.DataSet.GetBookmark;
    AssignFile(printFile, 'PrintFile.txt');
    Rewrite(printFile);
    liveGridTest.ExportNotification(esExportStart, -1);
    for i := 1 to liveGridTest.RowCount - 1 do
    begin
      liveGridTest.ExportNotification(esExportNewRow, i);
      holdItem := liveGridTest.Cells[0, i];
      BindSourceDB1.DataSet.Locate('item',holdItem,[loPartialKey]);
      writeln(printFile, BindSourceDB1.DataSet.FieldByName('item').AsString);
    end;
    liveGridTest.ExportNotification(esExportDone, -1);
    CloseFile(printFile);
    BindSourceDB1.DataSet.GotoBookmark(SavePlace);
    liveGridTest.SetFocus;
  end;
end;

The ExportNotification additions to the code seem to have resolved the issue. Thank you for your help!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.