DataTable to Editor and reverse

DataTable to Editor and reverse

EXPERBUYEXPERBUY Posts: 5Questions: 1Answers: 1
edited May 2015 in Editor

Hi,

I'm trying to change an instance of dataTable on Editor when user click a button. And the reverse too. At this time I transform my dataTable on Editor correctly. For the other way I just remove the "editor" class of my Table element and destroy the dataTable with .destroy() function. But my table is always editable.

How can I transform my Editor on simple DataTable ? Is there any function for that (or for destroy the Editor) ?

Thanks in advance.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    When you say the table is always editable - how is it editable? Are there buttons, or are you using inline editing?

    If button, then don't define the TableTools buttons. If inline editing, you will need to remove the event handlers that you have previously adding using the jQuery off method.

    Allan

  • EXPERBUYEXPERBUY Posts: 5Questions: 1Answers: 1

    Thanks Allan,

    My table have inline editing and TableTools buttons at the instantiation. After remove Editor, TablesTools buttons disapeare but I can use inline editing.

    So, with Jquery off method I disabled the inline editing... it's ok. I also removed some classes :

    $('#myTable').DataTable().destroy();
    $('#myTable').removeClass('editor');
    $('#myTable').removeClass('DTTT_selectable');
    $('#myTable').off( 'click', 'tbody td:not(:first-child)');
    

    After that I instantiate a DataTable :

    var table = $('#myTable').DataTable( {
            dom: 'T<"clear">lfrtip',
            tableTools: {
                "sSwfPath": "swf/copy_csv_xls_pdf.swf",
                "aButtons": [ 
                {
                    "sExtends": "copy",
                    "sButtonText": 'Copier'
                },
                {
                    "sExtends":    "collection",
                    "sButtonText": 'Exporter'
                    "aButtons":    [ "csv", "xls", "pdf" ]
                },
                {
                    "sExtends": "print",
                    "sButtonText": 'Imprimer' 
                }]
            },
            sRowSelect: "none"
    });
    

    With sRowSelect: "none" I would like disabled the row selection however I can select with the first column (like it was possible with my previous intantiation of Editor).

    How can I disabled this row selection ?

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    The sRowSelect: "none" should be inside the tableTools object, as it is a TableTools configuration option. It is currently being ignored.

    Allan

  • EXPERBUYEXPERBUY Posts: 5Questions: 1Answers: 1

    Hum... it's really strange. I move the option on tableTools like that :

    $('#myTable').DataTable( {
            dom: 'T<"clear">lfrtip',
            tableTools: {
                "sSwfPath": "swf/copy_csv_xls_pdf.swf",
                "sRowSelect": "none",
                "aButtons": [ 
                {
                    "sExtends": "copy",
                    "sButtonText": Translator.trans('copy') 
                },
                {
                    "sExtends":    "collection",
                    "sButtonText": Translator.trans('export'),
                    "aButtons":    [ "csv", "xls", "pdf" ]
                },
                {
                    "sExtends": "print",
                    "sButtonText": Translator.trans('print') 
                }]
            }
        });
    

    But I can alway select lines on my table. I wonder if some configurations are saved on memory or anything else.

    If it may help : Debug

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    That looks like it should work to me and I've just done a test to destroy a table and then recreate it without row selection and it appears to work. Can you give me a link to the page you are working on so I can debug it please.

    Allan

  • EXPERBUYEXPERBUY Posts: 5Questions: 1Answers: 1

    Sorry for my belated answer. My page is local and datas are confidentials, so I've made an example of my problem. Can I send it to you ?

    Thanks.

  • EXPERBUYEXPERBUY Posts: 5Questions: 1Answers: 1
    Answer ✓

    Thank's Allan !

    For others who have the same issue, I was using the version 2.2.3 of TableTools. The solution was to update it to 2.2.4.

    ps : Allan, can you mark this question to resolved ?

This discussion has been closed.