Custom "New" button

Custom "New" button

nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
edited November 2012 in General
Hi Allan,

How would I go about creating a custom "New" button to trigger the editor (and not using Tabletools)

N

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    You simply need to call the `create` method: http://editor.datatables.net/api/#create . The built in TableTools button is just a wrapper around that method - it boils down to:

    [code]
    editor.create( title, buttons );
    [/code]

    The buttons are defined in the same way as used in the `buttons` method: http://editor.datatables.net/docs/current/Editor.html#buttons .

    So you could do something like:

    [code]
    $('#mynewButton').click( function () {
    editor.create( 'New', {
    "label": 'Create',
    "fn": function (e) {
    this.submit();
    }
    }
    } );
    [/code]

    All of the TableTools buttons that Editor adds are just handy wrappers around the public API - no hidden parameters are accessed :-).

    Allan
This discussion has been closed.