Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                  <smart-grid id="grid"></smart-grid>
	<div class="options">
		<div class="caption">
		</div>
		<div class="option">
			<smart-button id="xlsxBtn">Export to Excel</smart-button>
		</div>
		<div class="option">
			<smart-button id="pdfBtn">Export to PDF</smart-button>
		</div>
		<div class="option">
			<smart-button id="htmlBtn">Export to HTML</smart-button>
		</div>
		<div class="option">
			<smart-button id="csvBtn">Export to CSV</smart-button>
		</div>
		<div class="option">
			<smart-button id="tsvBtn">Export to TSV</smart-button>
		</div>	
		<div class="option">
			<smart-button id="xmlBtn">Export to XML</smart-button>
		</div>			
	</div>

              
            
!

CSS

              
                html, body { padding: 0; margin: 0; }
smart-grid { width: auto; }
              
            
!

JS

              
                document.readyState === 'complete' ? init() : window.onload = init;

Smart('#grid', class {
    get properties() {
        return {
			dataSource: new Smart.DataAdapter(
			{
			    dataSource: [ { date: new Date() } ],
				dataFields:
                    [
                        'id: number',
                        'firstName: string',
                        'lastName: string',
                        'productName: string',
                        'quantity: number',
                        'price: number',
                        'total: number',
                        'date: date'
                    ]
			}),
			columns: [
				'id',
        { label: 'First Name', dataField: 'firstName' },
        { label: 'Last Name',  dataField: 'lastName' },
        { label: 'Product',    dataField: 'productName' },
        { label: 'Quantity',   dataField: 'quantity', align: 'right', cellsAlign: 'right',},
        { label: 'Unit Price', dataField: 'price', align: 'right', cellsAlign: 'right', cellsFormat: 'c2' },
        { label: 'Total',      dataField: 'total', align: 'right', cellsAlign: 'right', cellsFormat: 'c2' },
        { label: 'Date',       dataField: 'date', width: 400 }
			]
        }
    }
});

function init() { 
	const grid = document.querySelector('smart-grid');
	const xlsxBtn = document.querySelector('#xlsxBtn');
	const pdfBtn = document.querySelector('#pdfBtn');
	const csvBtn = document.querySelector('#csvBtn');
	const tsvBtn = document.querySelector('#tsvBtn');
	const xmlBtn = document.querySelector('#xmlBtn');
	const htmlBtn = document.querySelector('#htmlBtn');	
	
	xlsxBtn.addEventListener('click', () => {
		grid.exportData('xlsx');
	});
	
	pdfBtn.addEventListener('click', () => {
		grid.exportData('pdf');
	});
	
	csvBtn.addEventListener('click', () => {
		grid.exportData('csv');
	});
	
	tsvBtn.addEventListener('click', () => {
		grid.exportData('tsv');
	});
	
	xmlBtn.addEventListener('click', () => {
		grid.exportData('xml');
	});
	
	htmlBtn.addEventListener('click', () => {
		grid.exportData('html');
	});
}
              
            
!
999px

Console