Wijmo 5 - HTML in Headers
HTML
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.chart.min.js"></script>
<div class="container">
<h1>
HTML in Column Headers
</h1>
<p>
FlexGrid columns have an <b>isContentHtml</b> property that determines
whether the data bound to cells contains HTML rather than plain text/data.</p>
<p>
This property only applies to scrollable cells, though. If you want to
show HTML in the grid's column headers, use the <b>formatItem</b> event
and set the cells <b>innerHTML</b> property:</p>
<div id="theGrid"></div>
</div>
CSS
.wj-flexgrid {
margin: 12px;
}
.wj-flexchart {
height: 300px;
margin: 12px;
}
body {
margin-bottom: 24pt;
}
JavaScript
onload = function() {
// create some random data
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < countries.length; i++) {
data.push({
country: countries[i],
downloads: Math.round(Math.random() * 20000),
sales: Math.random() * 10000,
expenses: Math.random() * 5000
});
}
var view = new wijmo.collections.CollectionView(data);
// initialize the grid
var grid = new wijmo.grid.FlexGrid('#theGrid', {
columns: [
{ binding: 'country', header: 'Country<br><i>Names</i>' },
{ binding: 'sales', header: 'Sales<br><i>Result</i>' },
{ binding: 'expenses', header: 'Expenses' },
{ binding: 'downloads', header: 'Downloads', format: 'n0' }
],
autoGenerateColumns: false,
itemsSource: view,
selectionMode: wijmo.grid.SelectionMode.Row,
/* show HTML in column headers */
formatItem: function(s, e) {
if (e.panel == s.columnHeaders) {
e.cell.innerHTML = e.cell.textContent;
}
}
});
// autosize column header row to show line breaks
grid.autoSizeRow(0, true)
}