UNPKG

jqwidgets-scripts-custom

Version:

jQWidgets is an advanced jQuery, Angular 7, Vue, React, ASP .NET MVC, Custom Elements and HTML5 UI framework.

231 lines (213 loc) 11.3 kB
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>Custom Element DataTable RowTemplate</title> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" /> <meta name="description" content="This is an example of customized rendering rows in Custom Elements DataTable." /> <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" /> <link rel="stylesheet" href="../../../styles/demos.css" type="text/css" /> <script type="text/javascript" src="../../../scripts/webcomponents-lite.min.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.elements.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdatatable.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxtabs.js"></script> <script type="text/javascript" src="../../../scripts/demos.js"></script> <style> h4 { font-size: 14px; margin: 18px 0 15px 15px; } .tag-title-info { background: transparent; width: 1px; height: 0px; border-color: #4272b8 transparent #4272b8 #4272b8 !important; border-width: 26px 26px; border-style: solid; z-index: 1000; top: 0px; position: absolute; left: 598px; } .tag-title { font-size: 16px; color: #fff; position: absolute; z-index: 100; left: 0; line-height: 100%; background: #4272b8 !important; height: 52px; padding: 0px; margin: 0px; top: 0px; width: 500px; vertical-align: middle; } .cart-top { font-family: Arial, Helvetica, sans-serif; height: 35px; position: absolute; left: 500px; top: 0; color: #fff; padding: 16px 14px 1px 14px; font-size: 11px; font-weight: 400; background: #4272b8 !important; z-index: 199; } .cart-top p { font-weight: bold; font-size: 11px; background: url(../../../images/cart-icon.png) no-repeat right center; min-height: 16px; text-align: left; padding: 0 24px 0 0; margin-top: 2px; float: left; font-size: 11px; color: #fff; text-decoration: none; } </style> <script type="text/javascript"> var data = [ { laptops: [ { img: '../../../images/l-13.jpg', ram: '8GB DD3', cpu: 'Intel Core i7-3720QM', price: 2999, display: 15.4, hdd: '512GB SSD', model: 'Apple MacBook Pro' }, { img: '../../../images/l-14.jpg', ram: '8GB DD3', cpu: 'Intel Core i7-3667U', price: 1299, display: 13.3, hdd: '256GB SSD', model: 'Apple MacBook Air' }, { img: '../../../images/l-15.jpg', ram: '8GB DD3', cpu: 'Intel Core i7-3632QM', price: 2199, display: 15.4, hdd: '256GB SSD', model: 'Asus ZenBook UX51VZ' } ] }, { laptops: [ { img: '../../../images/l-16.jpg', ram: '4GB DD3', cpu: 'Intel Core i5-3317U', price: 1899, display: 13.3, hdd: '128GB SSD', model: 'ASUS TAICHI31-CX009H' }, { img: '../../../images/l-17.jpg', ram: '4GB DD3', cpu: 'Intel Core i7-3517U', price: 1799, display: 13.3, hdd: '628GB', model: 'Asus TX300CA-C4024H' }, { img: '../../../images/l-18.gif', ram: '16GB DD3', cpu: 'Intel Core i7-3820QM', price: 2499, display: 15.6, hdd: '1TB', model: 'Lenovo ThinkPad T530' } ] }, { laptops: [ { img: '../../../images/l-19.jpg', ram: '8GB DD3', cpu: 'Intel Core i5-3210M', price: 1499, display: 15.6, hdd: '750GB', model: 'Samsung Series 7 Chronos' }, { img: '../../../images/l-20.jpg', ram: '8GB DD3', cpu: 'Intel Core i7-3720QM', price: 1499, display: 17.3, hdd: '256GB SSD', model: 'HP EliteBook 8770w' }, { img: '../../../images/l-21.jpg', ram: '8GB DD3', cpu: 'Intel Core i7-3517U', price: 1499, display: 14.0, hdd: '512GB', model: 'Dell XPS 14' } ] }, { laptops: [ { img: '../../../images/l-22.jpg', ram: '32GB DD3', cpu: 'Intel Core i7-4800MQ', price: 3499, display: 17.3, hdd: '750GB', model: 'Dell Alienware 17' }, { img: '../../../images/l-23.jpg', ram: '8GB DD3', cpu: 'Intel Core i7-3537U', price: 1699, display: 15.6, hdd: '1TB', model: 'Acer Aspire R7-571G' }, { img: '../../../images/l-24.jpg', ram: '8GB DD3', cpu: 'Intel Core i7-4500U', price: 1599, display: 15.6, hdd: '256GB SSD', model: 'Acer Aspire V5-573G' } ] }, { laptops: [ { img: '../../../images/l-25.jpg', ram: '32GB DD3', cpu: 'Intel Core i7-4700MQ', price: 2199, display: 17.3, hdd: '1TB', model: 'Toshiba Qosmio X70-A-114' }, { img: '../../../images/l-26.gif', ram: '4GB DD3', cpu: 'Intel Core i7-3667U', price: 2699, display: 14.0, hdd: '256GB SSD', model: 'Lenovo Thinkpad X1 Carbon' }, { img: '../../../images/l-27.jpg', ram: '8GB DD3', cpu: 'Intel Core i5-3317U ', price: 1699, display: 12.5, hdd: '128GB SSD', model: 'Dell XPS Duo 12' } ] }, { laptops: [ { img: '../../../images/l-28.png', ram: '8GB DD3', cpu: 'Intel Core i7-3537U', price: 1799, display: 12.5, hdd: '256GB SSD', model: 'Lenovo ThinkPad Twist S230u' }, { img: '../../../images/l-29.jpg', ram: '4GB DD3', cpu: 'Intel Core i5-3317U ', price: 1299, display: 11.6, hdd: '128GB SSD', model: 'Sony Vaio Duo' }, { img: '../../../images/l-30.jpg', ram: '4GB DD3', cpu: 'Intel Core i5-3230M', price: 999, display: 15.5, hdd: '256GB SSD', model: 'Sony VAIO' } ] } ]; var source = { localData: data, dataType: 'array' }; var dataAdapter = new jqx.dataAdapter(source); var itemsInCart = 0; JQXElements.settings['dataTableSettings'] = { source: dataAdapter, sortable: true, pageable: true, pageSize: 2, pagerButtonsCount: 5, enableHover: false, selectionMode: 'none', rendered: _ => { var myButtons = document.querySelectorAll('jqx-button'); for (var i = 0; i < myButtons.length; i++) { myButtons[i].addEventListener('click', _ => { var cart = document.querySelector('#productCount'); itemsInCart++; cart.innerHTML = itemsInCart + ' products'; }); } }, columns: [ { text: 'Products', align: 'left', dataField: 'model', cellsRenderer: (row, column, value, rowData) => { var laptops = rowData.laptops; var container = '<div>' for (var i = 0; i < laptops.length; i++) { var laptop = laptops[i]; var item = document.createElement('div'); item.style.cssText = 'float: left; width: 210px; overflow: hidden; white-space: nowrap; height: 265px;'; var imageContainer = document.createElement('div'); imageContainer.style.cssText = 'margin: 5px; margin-bottom: 3px;'; var img = '<img width=160 height=120 style="display: block;" src="' + laptop.img + '"/>'; imageContainer.insertAdjacentHTML('beforeend', img); var info = '<div style="margin: 5px; margin-left: 10px; margin-bottom: 3px;">'; info += '<div><i>' + laptop.model + '</i></div>'; info += '<div>Price: $' + laptop.price + '</div>'; info += '<div>RAM: ' + laptop.ram + '</div>'; info += '<div>HDD: ' + laptop.hdd + '</div>'; info += '<div>CPU: ' + laptop.cpu + '</div>'; info += '<div>Display: ' + laptop.display + '</div>'; info += '</div>'; var buyButton = document.createElement('jqx-button'); buyButton.style.cssText = 'margin: 5px; left: -40px; position: relative; margin-left: 50%; margin-bottom: 3px;'; buyButton.innerHTML = 'Buy'; item.appendChild(imageContainer); item.insertAdjacentHTML('beforeend', info); item.appendChild(buyButton); container += item.outerHTML; } container += '</div>'; return container; } } ] }; </script> </head> <body> <div class="example-description"> Data Rows with customized rendering in Custom element DataTable. </div> <div class="cart-top"> <p id="productCount">0 products</p> </div> <div> <div> <div class="tag-title"> <h4>Welcome to our online shop!</h4> <span class="tag-title-info"></span> </div> </div> </div> <br /> <jqx-data-table settings="dataTableSettings"></jqx-data-table> </body> </html>