initComplete function blocks inline edit

initComplete function blocks inline edit

cha59cha59 Posts: 87Questions: 23Answers: 0

Hi
I'm having some of my code blocking for inline edit. My tabel is a lot like Fixed Columns Integration but I have added to extra search fields that specificly filters in just one column each. When I comment out this code, inline edit works. I can't figure out why it blocks for inline edit.

"initComplete": function(settings, json) {
        $('div.toolbar').html('<table><tr><td> Lærer: </td><td align="center"><input type="text" id="laerer_filter"></td><td> Hold: </td><td align="center"><input type="text" id="hold_filter"></td></tr></table>');

        $('#laerer_filter').on( 'keyup change', function () {//filtrerer lærer
        $('#example').DataTable().column( 5 ).search(
        $('#laerer_filter').val()
        ).draw();
        table.cell.blur();//modvirker at indtastning kommer i tal celle - fra Allan
        } );

        $('#hold_filter').on( 'keyup change', function () {//filtrerer hold
        $('#example').DataTable().column( 6 ).search(
        $('#hold_filter').val()
        ).draw();
        table.cell.blur();//modvirker at indtastning kommer i tal celle - fra Allan
        } );
}

I've used som html code for input to filter for 'laerer' in column 5 and for 'hold' in column 6. The two input cells are next to the datatable search field, and the 3 inputs can be combined in filtering, so it works exactly as I would want it to. But somehow it blocks for inlie edit.
Any ideas?
Best regards
Claus

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949
    Answer ✓

    Not sure why that code would stop inline editing from working. In trying to understand why you have table.cell.blur() in the keyup change events I found this thread of yours. Allan showed an example where you need to put cell.blur() in the focus event for your search inputs. So it should look more like this example:
    http://live.datatables.net/hapakugo/1/edit

    If you still have problems with inline editing maybe you can update my example to show the issue or provide a link to your page.

    Kevin

  • cha59cha59 Posts: 87Questions: 23Answers: 0

    Hi Kevin
    Thanks for your help. Before I posted, I could turn inline edit on and off by comments around the code. Now I can't. So something is pulling my leg. I'll get back when I have figured out how to get back to inline edit. I can see it's working in bin so...
    Best regards
    Claus

  • cha59cha59 Posts: 87Questions: 23Answers: 0

    Hi Kevin
    Can't explane it, but it has to do with keys combined with fixed colums and inline edit. I have given up on keys and is satisfied with my compromise, which is to forget keys and have inline edit on a click + enter. It´s not a big compromise, because of many lines in my tabel it was getting so slow, that you could easily out race blur with keys. Edit is fast and stabil, inline edit will only be for minor corrections.
    So thanks for your help.
    Best regards
    Claus

  • cha59cha59 Posts: 87Questions: 23Answers: 0
    edited April 2020

    Hi to any danes!
    What I did find out was, that the "danish-maker" blocked inline-editing:

    language: {
                "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Danish.json"
            },
    

    When this was deleted, inline-editing worked!
    Best regards
    Claus

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Hi Claus,

    When language.url is used, the DataTables initialisation becomes asynchronous - i.e. the script will continue before the table has fully loaded and the HTML updated.

    So if the rest of your script depends on the DataTables DOM being present, then that would explain what you are seeing. If you post your full script showing that problem I'm happy to take a look at it.

    Allan

This discussion has been closed.