Demo - Frozen Rows and Columns
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.pdf.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.pdf.min.js"></script>
<br/>
<br/>
<br/>
<div class="container">
<div id="theGrid"></div>
<button id="export" class="btn btn-default">
Export to PDF
</button>
</div>
CSS
.wj-flexgrid {
max-height: 250px;
margin: 10px 0;
}
body {
margin-bottom: 20px;
}
/* style frozen cells */
.wj-cell.wj-frozen:not(.wj-header):not(.wj-group):not(.wj-state-selected):not(.wj-state-multi-selected),
.wj-cell.wj-frozen.wj-alt:not(.wj-header):not(.wj-group):not(.wj-state-selected):not(.wj-state-multi-selected) {
background: rgb(255,255,125);
}
.wj-flexgrid .wj-cell.wj-frozen-col {
z-index: 0;
}
JavaScript
onload = function () {
// generate some random data
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < 10; i++) {
data.push({
id: i,
country: countries[i % countries.length],
downloads: Math.round(Math.random() * 20000),
sales: Math.random() * 10000,
expenses: Math.random() * 5000,
num1: Math.random() * 5000,
num2: Math.random() * 5000,
num3: Math.random() * 5000,
num4: Math.random() * 5000,
num5: Math.random() * 5000,
});
}
// default behavior: allow column reordering
var theGrid = new wijmo.grid.FlexGrid('#theGrid', {
itemsSource: data
});
document.getElementById("export").addEventListener("click", e => {
var d = new Date;
var dformat = [
d.getFullYear(),
d.getMonth() + 1,
d.getDate()].join('/') + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':');
var pdf = wijmo.pdf;
var gridPdf = wijmo.grid.pdf;
let doc = new pdf.PdfDocument({
header: {
declarative: {
text: '\t\t' + dformat
}
},
footer: {
declarative: {
text: '\t&[Page]\\&[Pages]'
}
},
ended: (sender, args) => pdf.saveBlob(args.blob, 'FlexGrid.pdf')
});
//
let settings = {
styles: {
cellStyle: {
backgroundColor: '#ffffff',
borderColor: '#c6c6c6'
},
altCellStyle: {
backgroundColor: '#f9f9f9'
},
groupCellStyle: {
backgroundColor: '#dddddd'
},
headerCellStyle: {
backgroundColor: '#eaeaea'
}
}
};
// gridPdf.FlexGridPdfConverter.draw(theGrid, doc, 200, null, settings);
...