ORIENT/modules/backend/formwidgets/grid/partials/_grid.htm

36 lines
1.1 KiB
HTML

<div id="dataTable" style="width:100%"></div>
<script>
var data = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#dataTable").handsontable({
// data: data,
colHeaders: <?= json_encode($columnHeaders) ?>,
colWidths: function(columnIndex) {
var widths = <?= json_encode($columnWidths) ?>,
totalWidth = $("#dataTable").innerWidth(),
usedWidth = 0,
unsetWidthCounts = 0,
current = parseInt(widths[columnIndex])
$.each(widths, function() {
var width = parseInt(this)
usedWidth += width
if (width <= 0) unsetWidthCounts++
})
if (current > 0)
return current
var remainingWidth = ((totalWidth - usedWidth) / unsetWidthCounts) - 2
return Math.max(remainingWidth, 100)
},
columns: <?= json_encode($columnDefinitions) ?>,
startRows: 6
});
</script>