Function addItem() becomes slow with many selectize elements #1832
Replies: 3 comments 2 replies
-
I'm a bit confused by your example. Are you loading a single selectize in each row that contains options from every row? I probably need a working example to make a good suggestion. Without more context I would at least suggest removing the for loop and initializing the data in the load event: $(".item").selectize({
load: function (query, callback) {
var data = [/* ... */];
callback(data);
},
}); it won't be a huge help, but might get you closer. your biggest issue is that no matter what else you do when you have nested loops, the more rows you have the worse performance is going to be. |
Beta Was this translation helpful? Give feedback.
-
Sorry for the misunderstanding…so i have a table with multiple rows and 4 columns containing selectize inputs. we want to provide the possibility to bulk edit (switch values) for one column. and i noticed that the time for this not only increases because of the loops, but also because of the method. |
Beta Was this translation helpful? Give feedback.
-
small table: https://jsfiddle.net/sa2qtpx3/2/ -> 1,5ms with more options it gets worse |
Beta Was this translation helpful? Give feedback.
-
I did:
(or gave a link to a demo on the Selectize docs)
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:
Beta Was this translation helpful? Give feedback.
All reactions