Editor deselecting on update

Editor deselecting on update

shantiramshantiram Posts: 13Questions: 5Answers: 2
edited August 2017 in Free community support

Hi
When editing certain tables, whenever i hit Update the row is deselected. Any idea what could be causing this?
Page: yogameditation.com/karto

This question has accepted answers - jump to:

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Answer ✓

    I believe that is the expected behaviour. Why is it a problem for you?

  • shantiramshantiram Posts: 13Questions: 5Answers: 2

    Ok yes I can see now that is the expected behaviour for server side tables... (But not client side).

    It becomes kind of disorienting with large tables...
    Also I have tried to implement stepping up/down rows with the keyboard, so the row deselecting whenever an edit is made becomes a bit annoying.
    According to this page: https://datatables.net/extensions/select/examples/initialisation/reload.html
    you should be able to set "deferRender: true" to fix this, but it doesn't work for me. Will post back if I come up with a solution.

  • shantiramshantiram Posts: 13Questions: 5Answers: 2
    Answer ✓

    If anyone's interested this is what I did. This maintains the selected position on redraw as well as between sessions.

    //Remember select position on update
    $.each(tables, function (index, value) {
    //'tables' is an array of datatables instances
        this.on('select', function () {
            //Add table id (with prefix "selected_") as key in local storage, add selected row id as value
            var key = "selected_" + this.id;
            var selected = $("#"+this.id+" .selected").attr('id');
            localStorage[key] = selected;
        });
            this.on('draw', function () {
            //Select saved row on draw
            if("#"+localStorage["selected_"+this.id]) {
            karto.tables[index].row("#"+localStorage["selected_"+this.id]).select();
            }
        });
    });
    
This discussion has been closed.