Hi,
I have some code that modifies the rendering of a choice field and adds an extra column to the choices:
This is done by following function
fd.spRendered(function () {
function changeChoiceFieldDemo(fieldName) {
myString = "myStringValue";
var template = '';
template += '<div style="white-space:nowrap;">';
template += '<span style="'
template += 'display: inline-block;'
template += 'width:50px;'
template += 'overflow: hidden;'
template += 'white-space:nowrap;'
template += 'text-overflow:ellipsis;'
template += 'border-right: 1px solid silver;'
template += '">'
template += '#: data # '
template += '</span> ';
template += '<span style="'
template += 'display: inline-block;'
template += 'width:250px;'
template += 'overflow: hidden;'
template += 'white-space:nowrap;'
template += 'text-overflow:ellipsis;'
template += '">'
template += '#: myString # '
template += '</span> ';
template += '</div>';
fd.field(fieldName).widgetOptions = {
template: template
}
}
changeChoiceFieldDemo("myChoice");
//renderForm();
});
However,
as you can see: the variable "myString" is globaly defined. If I change the code
from
myString = "myStringValue";
to
let myString = "myStringValue";
the function gives an error that the variable was not found, and the template is not excecuted... ![]()
So my question is: how can I handle this problem?
Is it possible to use local variables in my function that I can use in the template?
Main goal is that I can use parameters in my function of course, something like
fd.spRendered(function () {
function changeChoiceFieldDemo(fieldName, myString) {
//let myString = "myStringValue";
var template = '';
template += '<div style="white-space:nowrap;">';
template += '<span style="'
template += 'display: inline-block;'
template += 'width:50px;'
template += 'overflow: hidden;'
template += 'white-space:nowrap;'
template += 'text-overflow:ellipsis;'
template += 'border-right: 1px solid silver;'
template += '">'
template += '#: data # '
template += '</span> ';
template += '<span style="'
template += 'display: inline-block;'
template += 'width:250px;'
template += 'overflow: hidden;'
template += 'white-space:nowrap;'
template += 'text-overflow:ellipsis;'
template += '">'
template += '#: myString # '
template += '</span> ';
template += '</div>';
fd.field(fieldName).widgetOptions = {
template: template
}
}
changeChoiceFieldDemo("myChoice", "this is what I want to show on my choice field");
//renderForm();
});
Any help is appreciated,
Kind regards,
bartplessers





