multiple datatable editor instances on the same page but with HTML table as source

multiple datatable editor instances on the same page but with HTML table as source

x14841003x14841003 Posts: 33Questions: 9Answers: 0

Hello

I have tried to use 2 datatables editor instances on the same page. This works fine as soon as I keep an external source (json ajax) as the inline-editing\simple.html does. I declare 2 different editor instances to achieve that.

Now if i try to use 2 database editor instances on the same page but using 2 HTML tables (with different id's) and it does not work. Only the 1st instance is editable.

Has anybody tested this already ?

Thanks, Bye
x1484

This question has an accepted answers - jump to answer

Answers

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

    Hi @x14841003 ,

    It's working as expected here: http://live.datatables.net/ziguzeri/1/edit .

    Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • x14841003x14841003 Posts: 33Questions: 9Answers: 0
    edited June 2019

    Hello Colin

    First of all, MANY thanks for your help. I have used your link and i could reproduce the problem I faced.

    My problem was linked to "inline editing" but ok, I inserted for both "example1" and "example2" this :

    $('#example1').on( 'click', 'tbody td:not(:first-child)', function (e) {
            editor2.inline( this );
        } );
    

    And it was working nice !

    Then I removed the "buttons" clause from "example1" and "example2" getting this result :

    $("#example1").DataTable({
        dom: "Bfrtip",
        columns: [
                { data: 'name' },
                { data: 'position' },
                { data: 'office' },
                { data: 'age' },
                { data: 'start_date' },
                { data: 'salary' }
        ],
        select: true
      });
    

    and then the bug appeared ! the 2nd table was no more editable (but the 1st worked !)

    BUT if i leave the "buttons" clause empty for both "example1" & "example2" :

      $("#example1").DataTable({
        dom: "Bfrtip",
        columns: [
                { data: 'name' },
                { data: 'position' },
                { data: 'office' },
                { data: 'age' },
                { data: 'start_date' },
                { data: 'salary' }
        ],
        select: true,
        buttons: [
        ]
      });
    

    It works ! so the lesson is... be careful with clauses :-)

    Thanks so much ! Bye
    x1484

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

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

    Excellent, glad all working.

This discussion has been closed.