How to wrap cell text in a table?
How to wrap cell text in a table?
dtUser2011
Posts: 11Questions: 0Answers: 0
Hi,
I'm new to GUI development, and I'm using the DataTables API to create a table. I have a table with four cells, and the last two cells can have very long strings. Do you know how I can wrap the text in the cells? Currently, the long text just spews across the cells. Here is my current code:
HTML:
Server Port Name
Server Node Name
Storage Port Name
Storage Node Name
Javascript:
var linkOptions = {
"fnHeaderCallback": function( nHead, aData, iDisplayIndex ) {
$('td:eq(0)', nHead).css("background-color","transparent");
},
"bPaginate" : false,
"bFilter" : false,
"bInfo" : false,
"bAutoWidth" : false,
"aaData" : [],
"aaSorting": [[ 1, "alphanumeric-asc" ]],
"aoColumns" : [
{
"sTitle" : serverPortNameTitle,
"sWidth" : "230px",
"mDataProp" : "serverPortName",
"sType" : "string"
}, {
"sTitle" : serverNodeNameTitle,
"sWidth" : "230px",
"mDataProp" : "serverNodeName",
"sType" : "string"
}, {
"sTitle" : storagePortNameTitle,
"sWidth" : "230px",
"mDataProp" : "storagePortName",
"sType" : "string"
}, {
"sTitle" : storageNodeNameTitle,
"sWidth" : "230px",
"mDataProp" : "storageNodeName",
"sType" : "string"
}
]
};
var table_id = DOWNLINK_NAMESERVER_PORTS_TABLE_ID + '-' + portId;
return $(table_id).dataTable(linkOptions);
Thanks for your help in advance!
I'm new to GUI development, and I'm using the DataTables API to create a table. I have a table with four cells, and the last two cells can have very long strings. Do you know how I can wrap the text in the cells? Currently, the long text just spews across the cells. Here is my current code:
HTML:
Server Port Name
Server Node Name
Storage Port Name
Storage Node Name
Javascript:
var linkOptions = {
"fnHeaderCallback": function( nHead, aData, iDisplayIndex ) {
$('td:eq(0)', nHead).css("background-color","transparent");
},
"bPaginate" : false,
"bFilter" : false,
"bInfo" : false,
"bAutoWidth" : false,
"aaData" : [],
"aaSorting": [[ 1, "alphanumeric-asc" ]],
"aoColumns" : [
{
"sTitle" : serverPortNameTitle,
"sWidth" : "230px",
"mDataProp" : "serverPortName",
"sType" : "string"
}, {
"sTitle" : serverNodeNameTitle,
"sWidth" : "230px",
"mDataProp" : "serverNodeName",
"sType" : "string"
}, {
"sTitle" : storagePortNameTitle,
"sWidth" : "230px",
"mDataProp" : "storagePortName",
"sType" : "string"
}, {
"sTitle" : storageNodeNameTitle,
"sWidth" : "230px",
"mDataProp" : "storageNodeName",
"sType" : "string"
}
]
};
var table_id = DOWNLINK_NAMESERVER_PORTS_TABLE_ID + '-' + portId;
return $(table_id).dataTable(linkOptions);
Thanks for your help in advance!
This discussion has been closed.
Replies
Take a look at this thread
http://www.datatables.net/forums/discussion/12691/table-content-width-exceeds-header-width#Item_10
Allan
Thanks for your quick response! I thought the table cells should wrap automatically, too, but it doesn't. I've attached a link to the code here: http://live.datatables.net/uhunib/2/edit
td {word-wrap: break-word}