in my project, we are using data-tables for display the data, one of the column have text more than 200 characters, so the user wants that column have fixed width but whenever they want they can stretch the column width to see the full text in that. ( Ex: in excel we can adjust the column width ) like that we want to implement, is it possible.
Can you please suggest to do so
What I have tried:
$(document).ready(function () {
var table = $("#FMHelp").DataTable({
"ajax": {
"url": "/Help/GetHelpDetails/",
"type": "GET",
"datatype": "json"
},
"dom": 'Bfrtip',
"buttons": [{
extend: 'excel',
title: 'FM Help Details',
filename: 'FM Help Details',
text: "Export to Excel"
}
],
"pageLength": 15,
"lengthMenu": [15, 20, 30, 50, 75, 100],
"columns": [
{ "data": "ID" },
{ "data": "Description" },
{ "data": "Link" },
{ "data": "File" },
{ "data": "CreatedDate"},
{
mRender: function (data, type, row) {
var linkEdit = 'Edit';
linkEdit = linkEdit.replace("-1", row.ID);
var linkDelete = 'Delete';
linkDelete = linkDelete.replace("-1", row.ID);
return linkEdit;
}
}],
"columnDefs": [
{
"targets": [2],
"searchable": false,
"render": function (data, type, full, meta) {
data = '' + data + '';
return data;
}
},
{
"targets": [3],
"searchable": false,
"render": function (data, type, full, meta) {
data =
data = '' + data + '';
return data;
}
},
{
"targets": [4],
"searchable": false,
"render": function (value) {
if (value != null)
{
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"];
var pattern = /Date\(([^)]+)\)/;
var results = pattern.exec(value);
var dt = new Date(parseFloat(results[1]));
dt = dt.getDate() + "-" + months [dt.getMonth()] + "-" + dt.getFullYear();
return dt;
}
}
},
{
"targets": [ 5 ],
"searchable": false
}]
});