Sorting Multiple Tables

Sorting Multiple Tables

isport59isport59 Posts: 30Questions: 9Answers: 2

Yes!

I have 3 tables on my page. The first with Car Dealers. The second for car dealer ads. And, the third table with unlimited photos for each ad using the upload plugin. I did some nice work. My page is finally functional. All on one page.

http://192.81.170.116/dealers.html

The only glitch I encountered is the sorting. When I sort a column in the first table the second table looses its css formatting. If I sort a column in the second table the third table looses its formatting. But don't get me wrong the columns are sorting.

An answers to this issue would be greatly appreciated.

Mike

This question has accepted answers - jump to:

Answers

  • mRendermRender Posts: 151Questions: 26Answers: 13
    Answer ✓
    var table = $('#dealerships').DataTable();
    
        $('#dealerships').on( 'click', 'tr', function () {
            $('#carphotos').dataTable().fnClearTable();
    
            $('#cars').dataTable().fnDestroy();
    
            var did = table.row( this ).data();
            did = did.CarDealers.DealerID;
    

    did.CarDealers.DealerID is undefined so you can't redraw the table. That's why it's disappearing. Make sure you get the right information back after you sort. Once the variable did is getting back a valid something, it might work.

  • mRendermRender Posts: 151Questions: 26Answers: 13

    The same issue is with cid for the third table. The variable cid is undefined so the redraw is breaking.

  • isport59isport59 Posts: 30Questions: 9Answers: 2

    Added the following. It's something. Now it works fine. Thanks for the tip

    $('#dealerships').DataTable( {
            "scrollX" : false,
    
  • isport59isport59 Posts: 30Questions: 9Answers: 2
    edited May 2015 Answer ✓

    To answer my own question. This "scrollX" : false, doesn't quite work as expected. As a work around I've decided to use the following.

         $('#dealerships').DataTable( {
             "scrollY": "100%",        
        } );
    

    Sorting multiple tables now works!
    http://192.81.170.116/carsection.html

    Mike

This discussion has been closed.