datatable responsive+ changes column and data

datatable responsive+ changes column and data

ofirk12ofirk12 Posts: 15Questions: 8Answers: 1
edited May 2018 in Responsive

Hello i am trying to build page that you can choose the subject title and build the query so its mean that every time tha column change and the data, but the problem that the table is not responsive , its over the screen

<table id="reportTable" class="display" cellspacing="0" width="100%" >
    <thead>
         <tr>                            
         </tr>
    </thead>
    <tfoot>
          <tr>
           </tr>
    </tfoot>
</table>

  //if the table exist clean it 
    if($("#reportTable_wrapper").length > 0){
        $('#reportTable').empty();
        table.destroy();
        $("#reportTable>thead>tr").html("");
        $("#reportTable>tfoot>tr").html("");
     
    }
    topic=$('#topic').val().toString();
    columns = [];
    columnNames = $('#topic').val();
    for (var i in columnNames) {
          //make the column
          columns.push({data: columnNames[i]});
          $("#reportTable>thead>tr").append("<th>"+columnNames[i]+"</th>");
      $("#reportTable>tfoot>tr").append("<th>"+columnNames[i]+"</th>");
    }

    table= $('#reportTable').DataTable( {          
        ajax: {
                url: "url that works",
                type: "POST",
                data: { topic:topic} ,
                dataSrc: ''
        },
        processing: true,
        serverSide: true,
        order: [[0, 'asc']],
        columns: columns,
        responsive: true,
    } );

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @ofirk12 ,

    Nothing stands out as being wrong, you've set responsive. The only other obvious thing to check is that you're loading the responsive JS and CSS files.

    If that is the case, we're happy to take a look if you could link to a running page.

    Cheers,

    Colin

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Can you give me a link to a page showing the issue please?

    Thanks,
    Allan

  • ofirk12ofirk12 Posts: 15Questions: 8Answers: 1
    edited May 2018

    @colin and @allan ,its crm that i build so i sent you private link in pm

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @ofirk12 ,

    Thanks for that link - I took a look but my CSS isn't upto much. I suspect it's likely to be caused by the container that the table is using. This doesn't appear to be resizing, so the table just remains filling it out. Allan would be best placed to comment here, so handing over to him :)

    Cheers,

    Colin

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Could you try loading in the nightly version of Responsive please? If you could use the non-min version as well, that would be useful so I can trace it through.

    Thanks,
    Allan

  • ofirk12ofirk12 Posts: 15Questions: 8Answers: 1

    @allan i did it, i hope that i understand you good

This discussion has been closed.