Hi Dan
I’ve had a chance to play and have hit an issue. I’ve successfully integrated ‘choices’ with the following code:
<select
class="form-control"
name="choices-multiple-remove-button"
id="filter"
placeholder="This is a placeholder"
multiple
>
<option value="One">One</option>
<option value="Two">Two</option>
<option value="Three">Three</option>
</select>
<script>
document.addEventListener('DOMContentLoaded', function() {
var genericExamples = document.querySelectorAll('[data-trigger]');
for (let i = 0; i < genericExamples.length; i++) {
var element = genericExamples[i];
new Choices(element, {
allowHTML: true,
placeholderValue: 'This is a placeholder set in the config',
searchPlaceholderValue: 'This is a search placeholder',
});
}
var multipleCancelButton = new Choices(
'#filter',
{
allowHTML: true,
removeItemButton: true,
}
);
});
</script>
And I’ve changed my onRowFilter
to:
onRowFilter: (args) => {
const queries = args.filterParam.queries;
args.visible = false;
for (let i = 0; i < queries.length; i++) {
if (args.row.name.toUpperCase().indexOf(queries[i].toUpperCase()) !== -1) {
args.visible = true;
break;
}
}
var parent = args.row.parent();
if (parent && !parent.hiddenUsingFilter) {
args.visible = true;
}
},
I’m now confused with what I need to do with my ‘const app’ which is currently:
const app = {
elements: {
filter: document.querySelector("#filter"),
},
filter() {
// see dp.onRowFilter above
dp.rows.filter({
query: app.elements.filter.value,
});
},
init() {
app.elements.filter.addEventListener("change", function() {
app.filter();
});
}
};
app.init();
I also have no idea how to ensure that my multiple selected values from ‘choices’ are stored in an array.
I’m sorry to be thick, can you help please?