Bold BI®Unlock stunning dashboards with Bold BI®: 35+ widgets, 150+ data sources, AI agent & more. Try it for free!
Hello,
I am trying to empty the datasource of a combobox via javascript, but at the momento I try to do it I get the error Maximum call stack size exceeded.
I need to empty the datasource to reload it with a new one, but something is not working well with the code.
This is the sample code:
(Empty the DataSource) document.getElementById("lstEmpenhos").ej2_instances[0].dataSource = []; (Fill the DataSource with another content)
document.getElementById("lstEmpenhos").ej2_instances[0].dataSource = EmpenhoList;
After running that code, the dropdown arrow on the combobox turns into an spinning wheel and I get the error mentioned above.
Is there a solution for this problem?
Regards,
Alexandre
<div class="control-wrapper"> <div id="default" style='padding-top:75px;'> <ejs-combobox id="games" dataSource="@ViewBag.data" placeholder="Select a game" popupHeight="220px"> </ejs-combobox> </div> <ejs-button id="targetButton" content="Change"></ejs-button> </div> <script> window.onload = function () { document.getElementById('targetButton').onclick = function () { var comboObj = document.getElementById('games').ej2_instances[0]; comboObj.dataSource = []; comboObj.dataBind(); comboObj.dataSource = ["Golf", "Gymnastics", "Hockey", "Tennis"]; comboObj.dataBind(); } } </script> |
Hello Vinitha
The dataBind method solved my problem.
Thank you!
Alexandre