running query without persistent fields

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
etwoss
Posts: 4
Joined: Tue Nov 22, 2016 2:57 pm

running query without persistent fields

Post by etwoss »

Hi

I have a query 'select * from <viewname>'

i have no persistent fields, just want to export the dataset to excel,
However i want to translate the displaylabels , something like:

Code: Select all

for i := 0 to View.fields.count -1 do
begin
  View.Fields[i].DisplayLabel :=   
                  TsiLang.Translate(View.Fields[i].DisplayLabel);
end;
Is there any method which i can Use?
Would be great!!

Eric

isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hello,
There is no such "direct" method, but you may try to use GetStringValue() method to iterate through all existing strings and find your value and then retrieving it.
Best regards,
Igor Siticov.
etwoss
Posts: 4
Joined: Tue Nov 22, 2016 2:57 pm

Post by etwoss »

isiticov wrote:Hello,
There is no such "direct" method, but you may try to use GetStringValue() method to iterate through all existing strings and find your value and then retrieving it.

Would it not be nice to have such method? Not to hard to develop i think.

What you mean is trying to get the fieldsdisplay value as:


siLang1.GetStringValue(@siLang1.MultiLines,
Field.DisplayLabel, siLang1.ActiveLanguage);


Eric
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

No, I mean that if you know the values of Display_Label(s) then you can add them to Strings property with some IDs like DISPL_LBL_ID_N and translate. Changing N for every label you add. Then you can iterate through DISPL_LBL_ID_N and retrieve initial value, if it is the same as designed- then return GetStringValue(@Strings,...) with needed ID and needed language.
Hope this helps.
Best regards,
Igor Siticov.
etwoss
Posts: 4
Joined: Tue Nov 22, 2016 2:57 pm

Post by etwoss »

Hi

Thanks

When loading a file from disk with first param Strings, it only read the strings part and leave all other (displayLabels)?

Eric
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Yes,

Code: Select all

LoadFromFile(PropType: TStringsType; const AFileName: string; CanRewrite: Boolean)
method loads only specified property.
etwoss
Posts: 4
Joined: Tue Nov 22, 2016 2:57 pm

Post by etwoss »

Hi

Is "GetTextOrDefault" not faster than "GetStringValue"?

Eric
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

GetTextOrDefault returns only value for active language (and default if value not defined) but in your case you will need to obtain value of default language by GetStringValue and then you can use GetTextOrDefault to get active value if working only with Strings property.
Best regards,
Igor Siticov.
Post Reply