In table form controls - Issue with multiple table on same page

In table form controls - Issue with multiple table on same page

peterbrownepeterbrowne Posts: 45Questions: 12Answers: 0

I am using In table form controls:

https://editor.datatables.net/examples/simple/inTableControls.html

Using this with multiple tables on the same page (tables are hidden by default, and shown through a drop-down list), the class of the form control is not sufficient to identify the correct table. E.g.:

    $('#learning_event_table').on('click', 'a.editor_edit', function (e) {
        e.preventDefault();
        editor.edit( $(this).closest('tr'), {
            title: 'Edit record',
            buttons: 'Update'
        } );
    } );

                $('#amc_graduate_outcome_table').on('click', 'a.editor_edit', function (e) {
        e.preventDefault();
        editor.edit( $(this).closest('tr'), {
            title: 'Edit record',
            buttons: 'Update'
        } );
    } );

Editing a record in#amc_graduate_outcome_table, then attempting to edit a record in #learning_event_table, results in a record in #amc_graduate_outcome_table being available for edit.

A workaround may be to substitute the class a.editor_edit for an ID but I haven't tested this yet. Alternatively, find the closest table then row, which perhaps requires an update to the editor code??

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 6,526Questions: 0Answers: 1,122

    Hi @peterbrowne ,

    Each DataTable would need its own Editor instance - it looks you're sharing them between the table there - something like this.

    Cheers,

    Colin

  • peterbrownepeterbrowne Posts: 45Questions: 12Answers: 0
    edited November 8

    Thanks, you are right.

  • peterbrownepeterbrowne Posts: 45Questions: 12Answers: 0

    However, with assigning unique editor variable instances to the editors and datatables still results in significant lag.

  • colincolin Posts: 6,526Questions: 0Answers: 1,122
    Answer ✓

    Could you only initialise the table when the table becomes visible (or just before), that should reduce the lag of having to do them all at initialisation.

Sign In or Register to comment.