-
Notifications
You must be signed in to change notification settings - Fork 802
UI Set form fields label (caption) programmatically without losing is required handling
Victor Tomaili edited this page May 3, 2021
·
1 revision
Inspired by issue #941,
I thought to generalize and fully automate this issue (this is to use within xyzDialog.ts).
Here the code snippet for this:
var FieldToChangeLabel = this.form.TacMasterLayoutIsCheckedIn;
var Label = FieldToChangeLabel.getGridField().find('.caption');
var oldText = Label.prop('innerText');
if (oldText[0] == '*')
{
oldText = oldText.substr(1); // *** remove the leading '*' ***
}
var newText = "Jojo"; // *** Your new label goes here ***
var newContent = Label.prop('outerHTML').split(oldText).join(newText);
Label.prop('outerHTML', newContent);
This gets the current text of the label, removes it, adds the new text - all without removing the required '*' handling.
Hope, this helps someone.
With kind regards,
John
Copyright © Serenity Platform 2017-present. All rights reserved.
Documentation | Serene Template | Live Demo | Premium Support | Issues | Discussions