I have a table view which has an RTF field which is set to Tahoma, 0, 11.
At some point this field was set to Tahoma, 0, 12, and as my customer has continued to use the solution, the lines have become mixed between 11 and 12. This manifests when they print a quote on paper, and the font sizes are slightly different, enough to make the output look incongruous.
I have manually changed every line on one quote to 11 for each of the description lines, but there were over 100 rows, and it was tedious. However it did work, therefore I would assume that a loop, and a change of the element’s font property should do the same thing.
I would like to be able to loop through all records in a given quote and set the size (just the size as some lines are intended to be bold or different colours) to a value that I would like them to be able to choose (from a dropdown whose ondatachange runs the loop for example).
This returns the record object of row i, it doesn’t change the selection. For that you need to use foundset.setSelectedIndex(i) or controller.setSelectedIndex(i).
Also you use foundset and then you refer to another form. Is this the same form as you are looping over the foundset from ? Or is this a related form with line items.
If there latter shouldn’t you be looping over those lines as well or do you only want to change the font size on the first row of these related records?
Also if it’s a related form why not address it over the relationship. This is much safer because them Servoy knows in what context you access this form/foundset.
The font property on a rtf field holds the following tooltip:
Gets or sets the font name, style, and size of an element. font name - the name of the font family. style - the type of the font. (plain = 0; bold = 1; italic = 2; bold-italic = 3). size - the size of the font (in points). It only returns it’s correct value if it was explicitly set.
elements.elem.font = ‘Tahoma,1,11’;
So the font property only takes a string, it doesn’t have any other functions like fontsize().
Now, I am not sure this requires that the text be selected or not to apply the new font setting.
But you could try the following code. Please fix any relation/form logic when appropriate.
for ( var i = 1 ; i <= foundset.getSize(); i++ ) {
foundset.setSelectedIndex(i);
forms.line_items_complex_master.elements.description.selectAll(); // maybe not required
forms.line_items_complex_master.elements.description.font = 'Tahoma, 0, 12';
}
And it loops through (leaving the last line selected) but does absolutely nothing to the font.
The method is running in a form (line_items_complex_master) which has the loaded records (not through a relation) and it is looping properly, just not doing anything with the font…
Seem to be making progress now, the line does get selected, and the gui dropdown changes to the correct size, but the actual size of the font does not change.
This is a RTF field, I guess the size is embedded in the rtf markup?
it says this on one of the lines that is now explicitly set to 11:
{\rtf1\ansi{\fonttbl\f0\fnil Monospaced;\f1\fnil Tahoma;}\paperw11900\paperh16840\li0\ri0\fi0\f1\fs20\i0\b\ul0\cf0 To providing Design and Draughting services for July \par\li0\ri0\fi0 17h45 at 'a395.00 an hour\fs22\b0\ul0}