I am using SlickGrid (https://github.com/mleibman/SlickGrid) to display an editable table,
like this one, the one on the right:
But seems currently SlickGrid does not support this, how can this be done?
I am using SlickGrid (https://github.com/mleibman/SlickGrid) to display an editable table,
like this one, the one on the right:
But seems currently SlickGrid does not support this, how can this be done?
I found the following snippets from within the SlickGrid examples/example-column-group.html that worked for me. Note: I'm using this forked version of SlickGrid: https://github.com/6pac/SlickGrid/releases/tag/2.3.8
var options = {
createPreHeaderPanel: true,
showPreHeaderPanel: true,
preHeaderPanelHeight:23,
explicitInitialization:true
};
var columns = [];
columns.push({ id: "col1", name: "Col 1", field: "col1",columnGroup:"SuperHeading" });
columns.push({ id: "col2", name: "Col 2", field: "col2", columnGroup: "SuperHeading" });
grid = new Slick.Grid("#myGrid", dataview, columns, options);
grid.init();
var $preHeaderPanel = $(grid.getPreHeaderPanel())
.addClass("slick-header-columns")
.css('left', '-1000px')
.width(grid.getHeadersWidth());
$preHeaderPanel.parent().addClass("slick-header");
var headerColumnWidthDiff = grid.getHeaderColumnWidthDiff();
var m, header, lastColumnGroup = '', widthTotal = 0;
for (var i = 0; i < columns.length; i++) {
m = columns[i];
if (lastColumnGroup === m.columnGroup && i > 0) {
widthTotal += m.width;
header.width(widthTotal - headerColumnWidthDiff)
} else {
widthTotal = m.width;
header = $("<div class='ui-state-default slick-header-column' />")
.html("<span class='slick-column-name'>" + (m.columnGroup || '') + "</span>")
.width(m.width - headerColumnWidthDiff)
.appendTo($preHeaderPanel);
}
lastColumnGroup = m.columnGroup;
}
You can create header in other div by html code. And then make slickgrid header height 0px.
$("#container").find(".slick-header").css("height","0px");
But don't forget make resizable=false in column options.