How to display table in popup window using JavaScript?
You can display the JavaScript DataGrid inside the Dialog component while clicking the button. This can be achieved by defining the div element for DataGrid inside the Dialog element.
This is explained in the following sample code in which the DataGrid component is rendered inside the Dialog element and while clicking the button the Dialog will be shown.
HTML
<div id="defaultDialog"> <div id="Grid"></div> </div>
JS
// Grid component var grid = new ej.grids.Grid( { dataSource: gridData, allowPaging: true, columns: [ { field: 'OrderID', headerText: 'Order ID', width: 120, textAlign: 'Right' }, { field: 'CustomerName', headerText: 'Customer Name', width: 150 }, { field: 'Freight', width: 120, format: 'C2', textAlign: 'Right' } ], pageSettings: { pageSizes: true, pageSize: 5 } }); grid.appendTo('#Grid'); // Dialog Component var dialogObj = new ej.popups.Dialog({ header: 'Syncfusion Grid inside Dialog', target: document.getElementById('target'), width: '800px', buttons: [{ click: dlgButtonClick, buttonModel: { content: 'OK', isPrimary: true } }, { click: dlgButtonClick, buttonModel: { content: 'Cancel', cssClass: 'e-flat' } }], open: dialogOpen, close: dialogClose, visible: false, }); dialogObj.appendTo('#defaultDialog'); document.getElementById('dialogBtn').onclick = function () { dialogObj.show(); }; // Hide the Dialog function dlgButtonClick() { dialogObj.hide(); } // 'Open' Button will be shown if the Dialog is closed function dialogClose() { document.getElementById('dialogBtn').style.display = 'block'; } // 'Open' Button will be hidden if the Dialog is opened function dialogOpen() { document.getElementById('dialogBtn').style.display = 'none'; }
Output
Demo:
Conclusion
I hope you enjoyed learning about how to display table in popup window using JavaScript.
You can refer to our JavaScript Grid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
You can also explore our JavaScript Grid example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!