Example
Source
Run as server control
Use the
groupBy
and
having
properties to produce summary data using SQL aggregates
Include the Javascript library file
<script src="../dbnetgrid.js"></script>
Client-side script
window.onload = initGrid ////////////////////////////////////////////////////////////////////////////////////////////// function initGrid() ////////////////////////////////////////////////////////////////////////////////////////////// { var dbnetgrid1 = new DbNetGrid("dbnetgrid1") with (dbnetgrid1) { fromPart = "[order details]" connectionString = "samples" selectPart = ['productid','count(*) as mycount','avg(unitprice) as unitprice','Sum(quantity) as quantity','Sum(unitprice*quantity) as total_value','Avg(discount) as disc'] headings = ['Product Name','Count','Avg. Unit Price','Total Quantity','Total Value', 'Avg. Discount'] orderColumn = '2' orderSequence = 'desc' setColumnLookup('productid','productid','productname','products') setColumnProperty('quantity',"format:#,###,##0"); setColumnProperty('total_value','format:N') setColumnProperty('unitprice','format:N') setColumnProperty('disc','format:P') chart = true groupBy = "productid" having = "count(*) > 5" loadData() } }
HTML
<div id=dbnetgrid1></div>