Can a Datatable 1.10 exist in the same page as Datatable 2?

Can a Datatable 1.10 exist in the same page as Datatable 2?

minifiredragonminifiredragon Posts: 84Questions: 17Answers: 2
edited April 8 in DataTables 2

Just a quick yes or no on the subject, before I go an tear apart the table and rebuild it.

Scenario: I have a few datatables on 1 page. 2 are written in the 1.10 style using the dom: 'Blifrtip', formater. After the page is loaded, I load in a datatables 2 configured page, and even though I set (during the loading of the table):

DataTable.defaults.layout = 
    {
        topStart: null,
        topEnd: null,
        bottomStart: null,
        bottomEnd: null
    };

and use

layout: 
        {
            topStart:
            {
                pageLength: 
                { 
                    menu: [[10, 25, 50, 500, 1000, -1], [10, 25, 50, 500, 1000, "All"]],    
                },
                info: {},
                search : {},
                buttons: [
                    { extend: 'create', editor: t_walmartListingEditor },
                    { extend: 'edit', editor: t_walmartListingEditor },
                    { extend: 'remove', editor: t_walmartListingEditor },
                    { text: 'Submit',
                          action: function (e, dt, node, config) 
                          {
                                
                                // need to decide if we can send by options or send by all...
                          
                          }
                    }
                ],
            },
            
            bottom: ['info', 'paging'],
        },

The elements are stacked on top of each other instead of in a line like it should be. I thought it might be the CSS of the table messing with it, but I could not find anywhere it was.

The table loads like it should by itself, which is why I am asking. If it is a no, then I will dig deeper into the code.

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,273Questions: 1Answers: 10,611 Site admin
    Answer ✓

    Just a quick yes or no on the subject

    No.

    They both inhabit the same "space" (variable names) and cannot be used, without modification, on the same page.

    The legacy dom parameter will still work with DT2 (although if you specify both it and layout on the same table, layout will be used, not dom).

    What you are likely running into is that the DT2 CSS does not include styles for dom. You would need to add CSS for that if you wanted to continue using it.

    dom: 'Blifrtip'

    in layout is:

    layout: {
      top1Start: 'buttons'
    }
    

    the rest are in their detail location and thus should be fine.

    It might be worth updating to just using layout as such, rather than trying to write styles for dom.

    Allan

  • minifiredragonminifiredragon Posts: 84Questions: 17Answers: 2

    Thanks!

    After I posted this, I went in and changed the new table to use the 'dom' and it formatted the table like it should (also did a test where I made sure it was not css on my end). So I am torn with the simple add the dom, or go thru the other tables and change them to layout (and I do like layout more).

    But it is good to know that 2 different versions of a table do not like eachother.

  • allanallan Posts: 64,273Questions: 1Answers: 10,611 Site admin

    But it is good to know that 2 different versions of a table do not like eachother.

    Hah! You should hear them after a few beers. They trash talk each other something awful...

    Allan

Sign In or Register to comment.