Edit on dblclick

Edit on dblclick

nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
edited October 2012 in General
Hi,
How would I enable the editing of a row on dblclick?
Thks
N

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Call Editor's `edit` method in a dblclick event handler: http://editor.datatables.net/api/#edit

    Allan
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    Works like a charm.
    Now: how to disable the highlighting of rows?
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    Never mind:
    comment out "sRowSelect": "multi",
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    That's it :-). The trouble with click and dblclick is that there is simply no way to tell the difference between them, so yes, the click needs disabled in order to accept dblclick.

    Allan
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    So, I've added my custom edit button, but when I hit SAVE, the ID of the row is not passed to the server, and I get a server error.
    In the API-documentation, I do not see any mention of having to pass in the ID of the row.

    My code:

    editor.buttons( [
    {
    "label": "Cancel",
    "className":"btn btn-link",
    "fn": function () {
    this.close();
    }
    }, {
    "label": "Delete",
    "className":"btn btn-inverse",
    "fn": function () {

    this.remove( row_to_delete, 'Delete row', {
    "label": "Confirm",
    "fn": function () { this.submit(); }
    } );
    }
    }
    , {
    "label": "Save",
    "className":"btn",
    "fn": function () {
    this.submit();
    }
    }
    ] );
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    And the code to trigger the edit:

    $('.table_editable tbody').on('click',function(e){

    var $parent = $(e.target).parent();
    editor.edit( $parent,'Edit record');
    });
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > In the API-documentation, I do not see any mention of having to pass in the ID of the row.

    You don't - the ID must be on the row ( `row_to_delete` in this case) and this is what is sent to the server. Is the ID not present?

    Allan
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    The ID is not present in the data sent to the server.

    With what do I replace the string "row_to_delete"?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Editor fundamentally needs an ID on each row so it can track what rows are begin edited. Otherwise, when you submit a row to the server for updating, how would you tell the server what row it is that needs to be updated?

    Allan
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    OK, working now. Thanks.
This discussion has been closed.