Column Width does not work for me
Column Width does not work for me
James Wang
Posts: 3Questions: 2Answers: 0
I just bought a developer license of datatable editor and tried to use the following code to create a table. I would like to set the column width for the second column. But it does not work in either way (through CoumneDefs or Column attribute).
table = $('#container').DataTable({
dom: "rtip",
data: gene_data,
columnDefs: [
{ "width": "20%", "targets": 1 }
],
columns: [
{ data: "ID" },
{ data: "NAME", "width": "20%" },
{ data: "ELASTICITY" },
{ data: "TREND" },
{ data: "CANIN" },
{ data: "CANOUT" },
{ data: "DISCNT", className: 'editable' },
{ data: "MARKDOWN", className: 'editable' },
{ data: "FLYER", className: 'editable' },
{ data: "PRED_QTY" },
{ data: "CANIN_QTY" },
{ data: "CANOUT_QTY" },
{ data: "ADJ_PRED_QTY" },
{ data: "PRED_SALES" },
{ data: "PRED_PROFIT" }
],
select: {
style: 'os',
selector: 'td:first-child'
}
});
This discussion has been closed.
Answers
Found the problem. It is because the table header has no extra space for all the column names to show if the second column takes 20% of the width. When I use space to replace underscore in the column names, the second column is wider.