You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For any flex list you'll need to specify a container, this is the containerElement inside the renderer. For this example, there will also be a searchElement which is specified separately.
Each flex list is made up of:
An ID field, how each row is identified to avoid duplicates
A renderer, this is what creates the elements
Item callbacks, these are what pull the data
Optionally, you can include:
Search
Pagination
The example below uses the dummyjson.com API as fake data.
constbasicContainer=document.querySelector('#basicContainer')asHTMLDivElement;constsearch=document.querySelector('#basicSearch')asHTMLInputElement;letlist=newFlexList({renderer: newBasicListRenderer({containerElement: basicContainer,renderItem: (item: ListItem)=>{letproduct=item.dataasProduct;returnproduct.title;}}),search: newSearch({inputElement: search,fields: ['title']}),itemCallbacks: {load: async(page,limit)=>getRows(page,limit),search: async(query,page,limit)=>getRows(page,limit,query),},idField: 'id',noItemsText: 'There are currently no items.'});```