Problem wrapping data
Problem wrapping data
I am having a problem with large datasets in a table cell. I am using the PHP wordwrap to insert a "\n" in the text to limit the width to 40 characters. The text appears in the cell is wrapped at 40 characters but the cell width remains the width as if it was just one long line. My table init is:
var oTable = $('#datatable').dataTable({
"sDom": 'Rlfrtip',
"sPaginationType": "full_numbers",
"sDom": '<"top"lf>t<"bottom"rpi><"clear">',
"aLengthMenu": [[10,25,100, -1],[10,25,100,"All"]],
"oLanguage": {"sSearch": "Search all columns:"}
});
I am probably just missing something simple.
Thanks for any assistance,
Art
var oTable = $('#datatable').dataTable({
"sDom": 'Rlfrtip',
"sPaginationType": "full_numbers",
"sDom": '<"top"lf>t<"bottom"rpi><"clear">',
"aLengthMenu": [[10,25,100, -1],[10,25,100,"All"]],
"oLanguage": {"sSearch": "Search all columns:"}
});
I am probably just missing something simple.
Thanks for any assistance,
Art
This discussion has been closed.
Replies
Allan
I am guessing that maybe I have a conflict with some other JQuery module or maybe a wrong version.
Here are the style sheets and modules I am loading:
I believe the JQuery user interface is 1.8.12.
The DataTable table is dynamically filled from a ajax call to a database and then displayed in a jquery.ui tab. So a SQL query is created based on the user's request. It is passed to get_output.php:
var query = "select "+ flds +" from dataset where rownum < 5000 and ip = '"+ip+"'";
$.ajax({
url: "get_output.php",
data: {sql: query},
success: function (data) {
if ($('#DispData').is(':checked')) {
$("#tabs-2").html(data);
var oTable = $('#datatable').dataTable({
"sDom": 'Rlfrtip',
"sPaginationType": "full_numbers",
"sDom": '<"top"lf>t<"bottom"rpi><"clear">',
"aLengthMenu": [[10,25,100, -1],[10,25,100,"All"]],
"oLanguage": {"sSearch": "Search all columns:"}
});
/* Add a select menu for each TH element in the table footer */
$("tfoot th").each( function ( i ) {
this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i) );
$('select', this).change( function () {
oTable.fnFilter( $(this).val(), i );
} );
} );
}
else {$("#tabs-2").html("");}
}
});
get_output.php connects to the database, runs the query and and then formats and outputs the table:
$keys = "";
echo "\n\n";
while (OCIFetchInto($stmt, $row, OCI_ASSOC)) {
if ($th == 0) {
$keys = (array_keys($row));
echo "\n\n";
foreach ($keys as $k) {echo "" . $k . "\n";}
echo "\n";
$th = 1; // Table header done !
}
else {
echo "\n";
foreach ($keys as $k) {echo "" . wordwrap($row[$k],40,"\n") . "\n";}
echo "\n";
}
}
echo "";
foreach ($keys as $k) {echo "\n";}
echo "\n\n";
Each time the request is made it can return a different set of columns and/or data.
Thanks for any assistance.
As a workaround I've limited the size of the filter select fields in the fnCreateSelect function to the same as the data.
r += ''+aData[i].substr(0,40)+'';
Not a good solution but for now I think it will work for me.
Is there any way to skip filter select for certain columns? That may be a better approach since I really don't want to do a select on a paragraph of text.