how to set printable property at runtime
Posted:
Mon May 07, 2012 9:42 pm
by bobm
I have a report with several fields, one of them is an optional field with label.
The printable property for the label is currently set to Yes, but I would like to set it to No; then at runtime change it to Yes if the notes field has data.
Any suggestions on how to change the printable property at runtime when a field has data?
Re: how to set printable property at runtime
Posted:
Tue May 08, 2012 10:48 am
by Joas
You can change it using the solutionModel:
- Code: Select all
var _jsForm = solutionModel.getForm("yourform");
_jsLabel = _jsForm.getLabel("yourlabel");
_jsLabel.printable = true;
forms.yourform.controller.recreateUI();
But I think it would be a lot easier to use a calculation as the dataprovider of the label:
- Code: Select all
if (notes) {
return "yourtext/yourimage";
}
return "";
Then it is just "shown" and "hidden" automatically.
Re: how to set printable property at runtime
Posted:
Tue May 08, 2012 8:14 pm
by bobm
This looks like it should work, however I need the label to print only if a different field (note) has data - if the field has no data then the label should not print
- Code: Select all
var _jsForm = solutionModel.getForm("printForm");
var _jsLabel = _jsForm.getLabel("label");
var _jsNote = _jsForm.getComponent("note");
if (_jsNote != null){
_jsLabel.printable = true;
}
but this is not working.
Re: how to set printable property at runtime
Posted:
Thu Jun 21, 2012 12:55 pm
by omar
You forgot to recreate your form after changing it through the Solution Model. You should add:
- Code: Select all
_jsForm.controller.recreateUI();