Problem wrapping data

Problem wrapping data

cint116cint116 Posts: 6Questions: 0Answers: 0
edited July 2011 in General
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

Replies

  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    I'm not sure why it wouldn't be taking the BR into account - it should be! Can you give us a link please?

    Allan
  • cint116cint116 Posts: 6Questions: 0Answers: 0
    Unfortunately it an internal site so you would not be able to access it due to firewalls.

    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.
  • cint116cint116 Posts: 6Questions: 0Answers: 0
    I am a closer to identifying the cause of the long data cell size. The problem is related to the column filter. I am using the fnGetColumnData and fnCreateSelect code from the multi_filter_select example. If column select filters are disabled the table cell width is rendered correct.

    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.
  • cint116cint116 Posts: 6Questions: 0Answers: 0
    I am able to duplicate the condition in the multi_filter_select.html example by replacing one of the data cells with a paragraph of data that I manually added to limit the width.
This discussion has been closed.