This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to align/combine the fields for the report label?

Tags: None
(comma "," separated)
User avatar
jstaniek
Moderator
Posts
1027
Karma
2
OS
kexian wrote:I'm interested in doing mailing labels with Kexi but can't figure out how to align the fields on the label. Each person's first and last names are of different lengths so the space between the first and last names will always change. This also applies to the city, state, zipcode fields, which must be on the same line. Since there are no calculated fields in Kexi, how would one do a work around so the label spaces look professional and aligned?

Thanks,
Kexian

EDIT (jstaniek): moved this question from separate thread.


Best regards,
Jarosław Staniek
• Qt Certified Specialist
KEXI - Open Source Visual DB Apps Builder
• Request a feature or fix for KEXI here
May I help you? Please mention your app's version and OS when asking for help
User avatar
jstaniek
Moderator
Posts
1027
Karma
2
OS
Dear kexian,

Fields can be combined in reports using javascript at least in Kexi 2.4 or newer.

Assuming you have persons table with name and surname fields that you want combine: please insert Field report element onto your report, set data source to a table, set the field's Data Source property to:
Code: Select all
=field.value("name")+" "+field.value("surname")

In the Data View it will combine the field values with space between.

I prepared a sample database for you doing exactly that: http://kexi-project.org/pics/2.5/Report_fields.kexi. Here's the result:

Image

And the data on the report:

Image

Please note that the solution may be changed in the future to something even more handy, however we want to maintain backward compatibility.


Best regards,
Jarosław Staniek
• Qt Certified Specialist
KEXI - Open Source Visual DB Apps Builder
• Request a feature or fix for KEXI here
May I help you? Please mention your app's version and OS when asking for help
kexian
Registered Member
Posts
21
Karma
0
OS
Thank you for the information.
That solved my problem.
Can it do multiple lines in one field?
What else can one do with javascript and Kexi?
Is it in the documentation?

Kexian
User avatar
jstaniek
Moderator
Posts
1027
Karma
2
OS
kexian wrote:Can it do multiple lines in one field?

If your value, e.g. in column "name" contains end-of-line characters, it will be displayed in multiple lines in your report's Field element. Similarly, if you set Word Wrap to Yes in the Property Editor for your Field element, multiple lines will be used if needed. Make sure height of the Field element is large enough. Another case, you can set Data Source of the Field element to: =field.value("name")+"\n"+field.value("surname"). Note the \n. It will print name and surname in separate rows.

kexian wrote:What else can one do with javascript and Kexi?
Is it in the documentation?
Kexian

With regular scripts you can handle database operations, opening objects. In reports you can do special things. For example please take a look at excellent tutorial "Drilling Down on Facebook Data" at http://userbase.kde.org/Kexi/Tutorials. Feel free to ask report maintainer Adam Pigg to get more explanations.

There is also "Data importing using Javascript" sample database at http://kde-files.org/content/show.php?content=129683.

Scripting is experimental at the moment though, it supports multiple languages, what we found costly in terms of development. We're planning to focus on one language, so in result scripting will be reworked.

For more info on how to discover scripting capabilities, please see: http://community.kde.org/Kexi/Plugins/S ... umentation.


Best regards,
Jarosław Staniek
• Qt Certified Specialist
KEXI - Open Source Visual DB Apps Builder
• Request a feature or fix for KEXI here
May I help you? Please mention your app's version and OS when asking for help


Bookmarks



Who is online

Registered users: Bing [Bot], gfielding, Google [Bot], markhm, sethaaaa, Sogou [Bot], Yahoo [Bot]