Force to open edit form

Force to open edit form

vicfebovicfebo Posts: 20Questions: 0Answers: 0
edited December 2012 in Editor
Hello Allan,
I want to open the edit form when I click in the row. It´s posible to force this?

Thanks!

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Absolutely - you'd use something like this example: http://editor.datatables.net/release/DataTables/extras/Editor/examples/inlineControls.html - but rather than attaching the event handler to the `a` link in the table cells, you'd attach it to the `tr` element (i.e the table row).

    Allan
  • vicfebovicfebo Posts: 20Questions: 0Answers: 0
    I put this code:

    [code]
    $('#table_id').on('click', 'tr', function (e) {
    e.preventDefault();

    editor.edit(
    $(this).parents('tr')[0],
    'Edit record',
    { "label": "Update", "fn": function () { editor.submit() } }
    );
    } );
    [/code]

    but it doesn´t work :( Any idea Allan?

    Thank you!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Most likely because you don't have a table inside a table, which is what:

    > $(this).parents('tr')[0]

    suggests. `this` is already the `tr` element, so just pass it in rather than trying to walk back up the DOM tree.

    Allan
  • vicfebovicfebo Posts: 20Questions: 0Answers: 0
    You are my God Allan !! Thank you very much!

    I paste the solution:

    [code]
    $('#competitive_prices tbody').on('click', 'tr', function (e) {

    e.preventDefault();

    editor.edit(
    this,
    'Edit record',
    { "label": "Update", "fn": function () { editor.submit() } }
    );
    } );
    [/code]

    Bye!
This discussion has been closed.