Wijmo 5 - FlexGrid
HTML
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<div class="container">
<h1>FlexGrid</h1>
<hr>
<h3>Display pop up on double-click</h3>
<p>
Check the console for details about the cell
</p>
<div id="theGrid"></div>
<div id="popup">
<div class="wj-dialog-header">
Showing Popup
</div>
<div class="wj-dialog-body" tabindex="-1">
<h5>
Nothing to show here for now...
</h5>
</div>
<div class="wj-dialog-footer">
<button class="btn btn-primary wj-hide-ok">Yes</button>
<button class="btn btn-default wj-hide">No</button>
</div>
</div>
</div>
CSS
.wj-flexgrid {
height: 300px;
margin-bottom:24px
}
JavaScript
// create some random data
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < 20; i++) {
data.push({
country: countries[i%countries.length],
downloads: Math.round(Math.random() * 20000),
sales: Math.random() * 10000,
expenses: Math.random() * 5000
});
}
var popup = new wijmo.input.Popup('#popup');
// initialize a grid in code
var grid = new wijmo.grid.FlexGrid('#theGrid', {
autoGenerateColumns: false,
itemsSource: data,
isReadOnly: true,
columns: [
{ binding: 'country', header: 'Country' },
{ binding: 'downloads', header: 'Downloads' },
{ binding: 'sales', header: 'Sales', format: 'c' },
{ binding: 'expenses', header: 'Expenses', format: 'c' }
]
});
var element = document.getElementById('theGrid');
element.addEventListener('dblclick', function(e){
// determine which cell was clicked
var hitTest = grid.hitTest(e.clientX, e.cl ientY);
console.log("row: "+hitTest.row+"\ncol: "+hitTest.col);
var cellData = grid.getCellData(hitTest.row, hitTest.col)
console.log(cellData);
//show popup
popup.show(true);
});