You are not logged in.
Pages: 1
Hi,
I'm playing with the UIEdit, and I tried editing the record which has related fields ...
first of all I was quite amazed that the related fields were of combobox type
But all the combos were empty. Debugging and investigating I found out that fMainFieldName contains empty string for each model.
Following that path I changed SQLIte3Commons:9068 from "sftUTF8Text: begin" to "sftUTF8Text, sftAnsiText: begin"
(I haveall the fields declared as UTF8String, BTW ... but the type was always sftAnsiText).
so it now fills "non-unique" array of names ... but still the "unique" part is empty .. what am I doing wrong?
Offline
It's because you used sftAnsiText for your main field, whereas the framework expect it to be sftUTF8Text.
sftAnsiText will be converted as UTF-8 when stored in the DB, so perhaps it's not worth it here...
Online
ok, so I've reverted all the changes back to your version. Than declaret two records:
TSQLCourse = class(TSQLRecord)
private
//fields declaration here
published
property Instructor: TSQLPerson read fInstructor write fInstructor;
property Person: TSQLPerson read wPerson write fPerson;
and
TSQLPerson = class(TSQLRecord)
private
fName: RawUTF8;
fSurname: RawUTF8;
fPhone: RawUTF8;
published
property Name: RawUTF8 read fName write fName;
property Surname: RawUTF8 read fSurname write fSurname;
property Phone: RawUTF8 read fPhone write fPhone;
end;
I have some "person" records.
Now when I call TRecordEditForm on TSQLCourse, both comboboxes are empty ...
//debugging the model creation, I found out that in my case the P^.StoredProc never equals to integer(false), so the "Unique" flag is never being set to true ... thus fMainFieldName[false,x] is never filled with data.
// it seems that P^.StoredProc always equals to decimal number 1. At least for all the records I debugged it, including MainDemo records.
Last edited by migajek (2011-02-18 14:04:34)
Offline
You should set
property Name: RawUTF8 read fName write fName; stored false;
to make this field unique...
But it's not a good idea since two persons may have the same name!
I'll go and see what can be modified.
Online
stored false;
there's so much I have to learn about RTTI
yeah, indeed making that field unique is not the best idea ... but current way of handling automated relation edition makes it practically useless
Offline
We'll need to have some other custom display of record if there is no unique field: like Name+' '+FirstName or such...
Yes, that's what I did as for now - I did following:
function GetFullName: RawUTF8;
published
property FullName: RawUTF8 read GetFullName stored false;
/// ....
function TSQLPerson.GetFullName: RawUTF8;
begin
result:= fSurname + ', ' + fName;
end;
which actually works, but is tricky - creates completely unnecessary field in SQL, also displays the field in UIEditor.
If I don't define my own unique field, ID is default one, right?
So, how about using ID as unique field for internal operations (storing it in ComboBox.Items.Objects casted to TObject) while for displaying create virtual method in TSQLRecord, called GetUniqueDisplayName - which could be implemented by user, or - if it's not implemented - just use first sftUTF8Text field?
Offline
If you put a _ before the property name, like _FullName, it won't appear in the UIEditor.
Thanks, but
1. appears in the Grid (TSQLTableToGrid)
2. uses additional memory in the database (which is not that important, but still...)
3. I guess it's slower than ID-based record identification
but for a quick fix it's pretty good
Last edited by migajek (2011-02-19 13:25:53)
Offline
The UIEditor is best used with the global User Interface description of the framework.
You're trying to reinvent the wheel...
Take a look at the TSQLRibbon and TSQLRibbonTabParameters classes, as used for instance in our main demo.
By just filling TSQLRibbonTabParameters following fields, the UIEditor window know how to show or handle the data:
/// the associated hints to be displayed during the edition of this table
// - every field hint must be separated by a '|' character
// (e.g. 'The First Name|Its Company Name')
// - all fields need to be listed in this text resource, even if it won't
// be displayed on screen (enter a void item like ||)
// - you can define some value by setting a pointer to a resourcestring
EditFieldHints: PResStringRec;
/// write hints above field during the edition of this table
// - if EditExpandFieldHints is TRUE, the hints are written as text on the
// dialog, just above the field content; by default, hints are displayed as
// standard delayed popup when the mouse hover the field editor
EditExpandFieldHints: boolean;
/// the associated field name width (in pixels) to be used for creating
// the edition dialog for this table
EditFieldNameWidth: integer;
/// a CSV list of field names to be hidden in both editor and default report
// - handy to hide fields containing JSON data or the name of another
// sftRecord/sftID (i.e. TRecordReference/TSQLRecord published propet) fields
// - list is to be separated by commas (e.g. "RunLogJSON,OrdersJSON" or
// "ConnectionName")
EditFieldNameToHideCSV: RawUTF8;
/// if the default report must contain the edit field hints
// - i.e. if the resourcestring pointed by EditFieldHints must be used
// to display some text above every property value on the reports
EditFieldHintsToReport: boolean;
There is room to improvement, of course.
- Record selection via a TComboBox works only if the record has an unique main textual property.
- Validation needs to be extended in a n-Tier way - see your own article in http://synopse.info/forum/viewtopic.php?id=231 - I'm working on it.
Online
You're trying to reinvent the wheel...
indeed. that's because I needed to implement very simple TSQLRibbon equivalent, but TMS-independent.
Removing TMS dependencies from UIEdit form was fast and easy, so I decided to create very simple general editor with grid preview on my own ... anyway, thanks for the tips!
Offline
Pages: 1