...
employeesEdit.Bind(EventType.OnConfigureBinaryData, "configureImageFileName");
employeesEdit.Bind(EventType.OnFormElementValidationFailed, "configureValidationMessage");
employeesEdit.Bind(EventType.OnFormElementCreated, "configureFormElement");
...
<script type="text/javascript" class="source">
function configureFormElement(sender, args) {
switch (args.columnName)
{
case "notes":
args.formElement.rows = 4;
args.formElement.cols = 20;
break;
}
}
function configureImageFileName(sender, args) {
var fileName = sender.columnValue("photopath");
args.fileName = fileName.split('/').pop().replace(".bmp", ".jpg");
}
String.prototype.replaceLast = function (what, replacement) {
var pcs = this.split(what);
var lastPc = pcs.pop();
return pcs.join(what) + replacement + lastPc;
};
function configureValidationMessage(sender, args) {
if (args.key == "titleofcourtesy") {
const pattern = sender.formElement(args.key).attr("pattern");
const readablePattern = pattern.split('|').join(', ').replaceLast(",", " or");
args.value = `Title Of Courtesy should have a value of: ${readablePattern}`
}
}
</script>
|