#1 2014-11-20 07:11:40

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

Sharding

SAD wrote:

Starting with the revision 1.13 of the framework, dynamic arrays, TStrings and TCollection can be used as published properties in the TSQLRecord class definition. This won't be strong enough to implement all possible "Has many" architectures, but could be used in most case, when you need to add a list of records within a particular record, and when this list won't have to be referenced as a stand-alone table.

I've many cases in which this could be e very good solution  but... they are many and often need array of (packed) record.
So I tried to implement a generic new class tDynArrayToGrid, similar to SQLTableToGrid, able to display and edit any tDynArray of record but my knowledge of framework and of RTTI is not so good and, after a long time , i've not found a solution.

Can anyone help me please? Tx

Offline

#2 2014-11-20 07:37:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Sharding

Why just not export the dynamic array as JSON - see DynArraySaveJSON() in SynCommons.pas, then use the regular TSQLTableToGrid / JSONToDataSet() features?
With newer versions of Delphi, enhanced RTTI is used to serialize the array as proper JSON.
I think it would be easy to do and fast enough in practice.
This is how I would use it.

Online

#3 2014-11-20 19:22:10

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

Re: Sharding

Sounds good and fast but the ultimate purpose is to add,edit, delete array's data.
JSONToDataset returns a readonly dataset.
Well i can create from it a clientdataset but .... is there a simply way, when edited,  to synchronize array values to dataset ones? (I,ve not found a DatasetToJSON).

Offline

#4 2014-11-20 20:33:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Sharding

No those dataset are read only until you check the update rows and update them.

Online

#5 2014-11-21 07:27:03

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

Re: Sharding

AB, sorry to noise you :
certainly i've many and many things to learn because i cannot understand how to solve my problem.

I want to create an object like this :

   tRecordArrayToGrid = class
   protected
            fGrid       : tDbGrid;
            fRecInfo    : pointer;
            fValue      : ppointer;
            fDataset    : tClientDataset;
            fDatasource : tDataSource;
   public
         constructor create(aGrid : tDBGrid;
                                   aRecInfo : tTypeInfo;
                                   Var Value);
         destructor destroy;
   end;

The create method  has to create the dataset from Value and associate it to the dbgrid : I have understood how to do this.
The destroy method has to synchronize Value with dataset content  : I don't understand how to do this without create a method for each different record type.

Offline

Board footer

Powered by FluxBB