Hello,
I have found the posts on dynamically changing the items on a Dropdown menu, I was wondering if there was a way to dynamically change the list of items in a Multiple Choice field?
Something maybe like:
function changeDropDown() {
fd.field('DropDown1').widget.setDataSource(datasource);var datasource = [
{ value: 0, text: "A" },
{ value: 1, text: "B" },
{ value: 2, text: "C" },
{ value: 3, text: "D" },
{ value: 4, text: "E" }
];
fd.field('DropDown1').widget.setDataSource(datasource);
fd.field('DropDown1').widget.setOptions({dataTextField : 'text', dataValueField: 'value'});
}
fd.field('searchText').$on('change', changeDropDown)
changeDropDown();
but for Multiple Choice?
Thanks,
Mike M
Hello @mmendes,
Welcome to Plumsail Community!
Please try out the code below, it works for single and multiple choice dropdowns.
var datasource = [
{ value: 0, text: "A" },
{ value: 1, text: "B" },
{ value: 2, text: "C" },
{ value: 3, text: "D" },
{ value: 4, text: "E" }
];
fd.field('DropDown1').widget.setDataSource({
data: datasource
});
fd.field('DropDown1').widget.setOptions({
dataTextField: "text",
dataValueField: "value"
})
Hi Nikita,
I have tried out the code below and confirmed it works for multiple select dropdowns.
I am looking for a similar solution but for multi-select checkboxes.
Does such a solution exist?
Thanks,
Mike M
Hello @mmendes,
I'm sorry, I misunderstood you.
For the Multiple Choice field that is displayed as checkboxes, you can use the code below to set the options dynamically.
var datasource = ['test', 'test1', 'test2', 'test3'];
fd.field('Checkboxes1').options = datasource
You can change the labels of the checkboxes using jQuery:
var labels = $(fd.field('Checkboxes1').$el).find('label');
labels.each(function(index, label){
var html = $(label).html();
var text = $(label).text();
if(text.includes('test')) {
$(label).text('NewText')
}
});
If this option is not suitable for you, we can offer paid support. Please contact us by email [email protected] for more information.