TMSFMXLiveGrid Fetching all Records

Hi there


I have TMSFMXLiveGrid connected thru Livebinding to TAureliusDataSet (BindSourceDB)

It is loading all the records, and should be loading only the visible ones.

The table is big, 10K records

I have 2 fields from bindsource connected to LiveGrid (not using that * <-> * ) 

TAureliusDataSet is suplied with a Cursor Criteria

Data is shown correctly after load.

I had to add a Take(30) on the Cursor Criteria to load only 30 otherwise it goes all the way to 10K

I have no clue, asked Wagner and he said is not Aurelius.

Hi, 


We are using LiveBindings, which is reponsible for buffering and loading records. Are you able to reproduce this in a TGrid?
Hi

I have placed a TGrid and wired the same way and I can confirm the same behavior is happening, it is loading all the records.

Eduardo

BindSource is connected to a AureliusDataSet and there is no other things connected to it. Except a TEdit to show the Customer Name.


I am using Seattle. Is there anything that can cause this situation? For while I was OK with this because users did not have big tables, now this is changing fast.

Hi, 


If the issue is reproducible with TGrid, then this is unfortunately a LiveBindings issue, not a TTMSFMXLiveGrid issue. You should contact Embarcadero about this issue.

If this is a Livebinding issue how are you able to make it work in your side?


Do you have it working on seattle ?

I know there are a lot of bugs on delphi, but if works with your should work with me, please let me know how to test in my side.

I have made a simples project with the following:


1 tstringgrid
1 tgrid
1 ttmsfmxlivegrid

as a source I used UniTable and UniConnection to a PostGre Database

This is a new blank project from scratch.

I setup UniTable to NOT fetch all and 25 rows loading, from a table with almos 20K records

I have livebinded one per time to the bindsource connected to the UniTable and run the project.

For EACH one of the controls the full records were loaded.

My goal here is to remove any interference from my application or even Aurelius.

What you have said about testing with TGrid is true, HOWEVER it also demonstrates that TMSLiveGrid DOES NOT WORK as advertised, since it is not loading only the records needed.

Granted that could be a livebinding problem, but I have not find anything saying that LiveGrid is limited by Livebinding problems. 

This test application is the minimal and simplest possible just to see TMSLiveGrid works. It has the same behavior using AureliusDataSet.

I need to know what is the required setup in order to see LiveGrid using LIvebinding and doing the gradual loading in Seattle as defined on Documentation.

It does not work with UniDac neither Aurelius.

Thank you !

Hi, 


The TTMSFMXLiveGrid uses the same technique as the TGrid, TStringGrid uses a different technique and loads all records at once. TGrid should only load the visible records. There are a set of guidelines to follow when setting up LiveBindings, which we have following during development. We have tested this here with a TClientDataSet and could not reproduce the issue. If the issue persists, then there must be a setup error in your application, or an error in the FMX framework, something that we cannot fix on our side. 

Alternatively you could use TTMSFNCGrid (available at http://www.tmssoftware.com/site/tmsfncuipack.asp), which has a separate database adapter and does not use LiveBindings to load the records.

Pieter, sorry to get to this again


Is it possible to test in your side using UniDAC ou Aurelius to really make sure it does not work? 

LiveGrid should be working with Aurelius, it is a TMS product, should be compatible, what i know is that Aurelius can load on demand.

I am using it all around my application and it will be a really bad thing if that is the case. 

Thanks

We have retested this here with a default FireMonkey TGrid with LiveBindings and we see the same behavior in a TGrid. Our LiveBindings implementation in TTMSFMXLiveGrid is the same as the standard FireMonkey TGrid and this is a clear proof that the issue is either in the LiveBindings mechanism itself or in Aurelius and not in TTMSFMXLiveGrid.


According to the manual:


TTMSFMXGrid & TTMSFMXLiveGrid 
 
For binding data to the grid, there are 2 types of grids that can be used. The TTMSFMXGrid is able to bind to data and load all records at once. This type of grid can then optionally be disconnected by setting the property SaveDataSetData to true before deactivating the dataset to persist the data inside the grid. 
 
After data is persisted and the grid doesn’t have an active connection anymore, the grid can be used to apply filtering, grouping and sorting. 
 
The TTMSFMXLiveGrid loads the data on demand. A database with many records loads faster than the TTMSFMXGrid implementation. The SaveDataSetData property doesn’t have any effect on this grid because when the connection is deactivated the data is removed. Sorting, grouping and filtering on this grid directly are not supported. For each operation that has effect on the data, it must be applied directly on the dataset, which will automatically update the data inside the grid, if it has an active connection. Below is a sample how sorting is applied when the grid has an active connection.

I could not find anything telling me that there are exceptions. I tested it against UniDac and did not work either. So what are the conditions for the LiveGrid to work as defined on the manual?

Sorry, but proof only I can consider if I get a minimal project demonstrating the functionality on my computer. Then I can compare and understand what is different from Aurelius or Unidac

I need to understand what is wrong, I made a big project counting on that. If I am doing something wrong, or I did not understand how it should work I want to clarify it.

Thank you!

Your own words on June 29:


"I have placed a TGrid and wired the same way and I can confirm the same behavior is happening, it is loading all the records."

Please accept this as a final answer, TTMSFMXLiveGrid handles LiveBindings exactly the same way as TGrid.  It is NOT the grid that is responsible for loading all records, it is the LiveBindings itself together with the dataset.

ok


Please, I suggest to correct the documentation about this product and clarify that it will work only when livebindings are in the mood for that. 

FWIW I tested this today with Aurelius and the FNC grid and it all worked perfectly.  So at least there is a way of paging data to a grid in Fire Monkey.




procedure TForm4.AdapterGetRecordCount( Sender: TObject; var ARecordCount: Integer );
begin
  ARecordCount := ads.RecordCount;
end;


procedure TForm4.btnOpenClick( Sender: TObject );
begin
  ads.Open;
  Adapter.Grid       := grd;
  Adapter.DataSource := ds;
  Adapter.Active     := True;
end;


procedure TForm4.FormDestroy( Sender: TObject );
begin
  FManager.Free;
end;


procedure TForm4.FormCreate( Sender: TObject );
begin
  FConn    := TFireDacFirebirdConnection.CreateConnection;
  FManager := TObjectManager.Create( FConn );
  ads.SetSourceCriteria( FManager.Find< TContract >, 30 );
  ads.RecordCountMode := TRecordCountMode.Retrieve;
end;



Set the fetch options of dataset to fmManual. After you open a query fetch some rows how many do you want for first fetching. And if user is scrolling down side of a grid fetch more rows.


        FDQuery1.open;
if FDQuery1.Active then
begin
FDQuery1.FetchOptions.RowsetSize := 100;
FDQuery1.FetchNext;
end;


procedure TfrmMain.FDQuery1AfterGetRecords(DataSet: TFDDataSet);
begin
    buttonfetch.Enabled:=not FDQuery1.SourceEOF;
end;


for checking user needs more records  set  fdquery1onscroll event  or grids on row changed  as buttonfetchclick(); 

procedure buttonfetchclick(sender:Tobject);
begin
if not FDQuery1.SourceEOF then
begin
FDQuery1.FetchOptions.RowsetSize := 60;
FDQuery1.FetchNext;
        end else begin
            buttonfetch.Enabled:=false;
end;
end;