You are not logged in.
I would like to add RecNo (1 to number of records) field to TSQLTableJSON before displaying it in TSQLTableToGrid.
TSQLTableJSON content is taken from server with TSQLRecord.CreateAndFillPrepare/FillPrepare it has several fields and I would like to add calculated/custom RecNo field as first one, so final result would be something like:
RecNo Field1 Field2
---------------------------------
1 Value11 Value12
2 Value21 Value22
3 Value31 Value32
...
underlying TSQLRecord is something like:
TSQLSomeRec = class(TSQLRecord)
private
FField1: RawUTF8;
FField2: RawUTF8;
published
property Field1: RawUTF8 index 5 read FField1 write FField1;
property Field2: RawUTF8 index 10 read FField2 write FField2;
end;
What is the prefered/mORMot way of doing something like this?
Offline
Isn't it the already existing ID field?
Or an explicit increasing number?
Sorry for late reply, field doesn't exists in the table, it's not ID. It should be a new client side only field (I need it for displaying and printing) and it's values should go from 1 to number of records (so auto increasing).
Offline
Like a TTable.RecNo?
Offline
So the TSQLTableJSON needs to be modified once loaded, or the JSON could simply be modified before affecting it to the TSQLTableJSON.
I guess using TDocVariant is a very easy way of adding such a field values, before filling TSQLTableJSON.
Online
> So the TSQLTableJSON needs to be modified once loaded, or the JSON could simply be modified before affecting it to the TSQLTableJSON.
> I guess using TDocVariant is a very easy way of adding such a field values, before filling TSQLTableJSON.
Thanks, I was hoping there's some better way to avoid double processing of json dataset.
I'll try first to make TSQLTableJSON descendant and see if it's possible to make inplace changes.
On a general note, I think that TSQLTable would benefit of adding some easy to use calculated fields, like we have in standard TDataset.
Offline