JQuery DataTable
Set the columns property of the jqxDataTable. Author: http://jqwidgets.com
by txhi
HTML
<link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<script src="http://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<script src="https://jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/generatedata.js"></script>
<div id="table"></div>
JavaScript
var data = generatedata(50);
var source = {
localData: data,
dataType: "array",
dataFields: [{
name: 'firstname',
type: 'string'
}, {
name: 'lastname',
type: 'string'
}, {
name: 'date',
type: 'date'
}, {
name: 'productname',
type: 'string'
}, {
name: 'quantity',
type: 'number'
}, {
name: 'price',
type: 'number'
}, {
name: 'total',
type: 'number'
}]
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#table").jqxDataTable({
width: 670,
pageable: true,
theme: 'energyblue',
editable: true,
pagerButtonsCount: 10,
source: dataAdapter,
columnsResize: true,
columns: [{
text: 'Name',
dataField: 'firstname',
width: 70
}, {
text: 'Last Name',
dataField: 'lastname',
width: 70
}, {
text: 'Date',
editable: false,
dataField: 'date',
cellsFormat: 'dd-MMM-yyyy',
width: 100
}, {
text: 'Product',
editable: false,
dataField: 'productname',
width: 180
}, {
text: 'Quantity',
dataField: 'quantity',
width: 80,
cellsAlign: 'right',
align: 'right'
}, {
text: 'Unit Price',
dataField: 'price',
width: 90,
cellsAlign: 'right',
align: 'right',
cellsFormat: 'c2'
}, {
text: 'Total',
dataField: 'total',
cellsAlign: 'right',
align: 'right',
cellsFormat: 'c2'
}]
});