Skip to content

Function addItem() becomes slow with many selectize elements #1823

@herrniffler

Description

@herrniffler

I did:

  • Search for if my issue has already been submitted
  • Make sure I'm reporting something precise that needs to be fixed
  • Give my issue a descriptive and concise title
  • Create a minimal working example on JsFiddle or Codepen
    (or gave a link to a demo on the Selectize docs)
  • Indicate precise steps to reproduce in numbers and the result,
    like below

We use selectize in a table at ours. At e.g. 20 rows = 80 selectize elements, the addItem() function needs around 20ms per call. With 400 rows = 1600 elements, the function then needs ~150 ms per call. Therefore it takes much longer to do a bulk edit with 400 lines than with 20 lines and not only because of the number of elements.
Is there a way to speed it up or reduce the time to 20ms for many elements?

the bulk edit js:

function bulk_edit_dropdown_multi(selector, origin) {
    let dropdowns = origin.closest('table').querySelectorAll(`select.${selector}`);
    for (let dropdown of dropdowns) {
        let dropdownSelectize = dropdown.selectize;
        dropdownSelectize.clear(origin.options.length > 0);
        for (let i = 0; i < origin.options.length; i++) {
            dropdownSelectize.addItem(origin.options[i].value, i < origin.options.length - 1);
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions