ID | ||
---|---|---|
1 | white | 20564 |
2 | cyan | 80370 |
3 | grey | 40667 |
4 | purple | 69124 |
5 | grey | 92628 |
6 | black | 42057 |
7 | silver | 12974 |
8 | gold | 38113 |
9 | silver | 35729 |
10 | cyan | 21899 |
11 | black | 43400 |
12 | maroon | 65622 |
For large dynamic lists for which we store data in the memory, filtering is no different from sorting and
otherwise rendering the list. This example shows filtering in a specific scenario where the list is small
enough to make it feasible to render it in whole. Here we filter the list not by re-rendering every node but
toggling their hidden
attribute.
This technique can be applied for lists that have fewer than a few hundred items and are not paginated. Do not forget to test the performance, though, because the performance also depends on other factors such as the number of nodes in each row, styling, etc.
We have included an example of sorting as well. This implementation of sorting relies on the DOM alone, and also serves as a demonstration of how sorting and filtering combine in this scenario.