Category / Section
How to use getDataList method in Listbox
1 min read
This article explains the way to use the getDataList method in the Listbox component.
You can use the getDataList method to get the updated data in the ListBox. If you perform any action in the ListBox, you can use the getDataList method to know the changes made.
HTML
<div class="col-lg-12 control-section"> <div id="listbox-control"> <h4>Select your favorite car:</h4> <input id="listbox"> </div> <button id= "infobtn">GetDataList</button> </div>
TS
// Initialize ListBox component. let listObj: ListBox = new ListBox({ // Set the data source property. dataSource: (data as any).info, allowDragAndDrop: true }); listObj.appendTo("#listbox"); let toggleBtn: Button = new Button({ cssClass: "e-info" }); toggleBtn.appendTo("#infobtn"); toggleBtn.element.onclick = (): void => { let Data = listObj.getDataList(); console.log(Data); };
Refer to the working sample for additional details and implementation: Sample
Also please refer the below UG Documentation link,
https://ej2.syncfusion.com/documentation/list-box/getting-started/
https://ej2.syncfusion.com/documentation/api/list-box/#getdatalist