creating dynamic columns

creating dynamic columns

saravananramsaravananram Posts: 1Questions: 0Answers: 0
edited January 2013 in DataTables 1.9
How to create a dynamic columns along with data in jquery data table.Pls help.

Replies

  • dsmith505dsmith505 Posts: 2Questions: 0Answers: 0
    I have one way to do it. I use a jsp and pass the column names and data in on a bean. It works with a varying number of columns and data values as long as the number of data values in each row matches the number of columns in the header:







    Query Results



    var dataVar = <%= viewerData %>;
    var colNames = <%= columnNames %>;

    $(document).ready(function() {
    $('#exampleTable').dataTable({
    sPaginationType:"full_numbers",
    bJQueryUI: true,
    bScrollAutoCss: true,
    aoColumns: colNames,
    aaData: dataVar,
    bScrollCollapse: true,
    sScrollx: "100%",
    sScrollXInner: "600%"
    });
    } );

    where the view data is a string that looks like: [["val1", "val2", "val3"],["val1a", "val2a", "val3a"]]"
    and the columnNames looks like [{sTitle:"col1"},{sTitle:"Col2"},{sTitle:"Col3"}]

    The problem I have had is getting the horizontal scrolling to work. No matter what vaues I use for xScrollx and sScrollXInner it never displays the horizontal scroll bar. If I add columns it just makes the displayed columns smaller.
This discussion has been closed.