In-Line Editing

In-Line Editing

hubonehubone Posts: 13Questions: 4Answers: 0

I installed script using the http://editor.datatables.net/generator/index

I want to allow In line editing (where I can click on a cell and edit it instead of clicking the edit button. How do I do that?

Also how can I have a field where I can attach an image?

Answers

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Hi,

    Generator is a quick start tool only - it does not show all of the options of Editor. To get the full use from Editor you need to use its API - specifically for inline editing you would use the inline() method. There is an example available on the site.

    Also how can I have a field where I can attach an image?

    Use the upload field type. Example.

    Allan

  • hubonehubone Posts: 13Questions: 4Answers: 0

    Allan thanks a lot for your help, but I'm very confused. basically right now I'm trying to use the examples/inline-editing/responsive.html because I don't know how to setup my own page. I'm trying to edit the field names in that page, and in the staff.php page and in the database but I'm getting the JSON error.

    Basically I want all text fields about 10 different fields that I want to name, 1 other field to upload image, and 1 field that auto generate a number (that no one is allowed to edit). I want to be able to inline edit those fields.

  • hubonehubone Posts: 13Questions: 4Answers: 0
    edited December 2015

    I dont understand how to use API?

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Did you successfully use Generator to create an editable table? If so, then all you need to do is use the inline() method like in the example I linked to:

        $('#example').on( 'click', 'tbody td', function (e) {
            editor.inline( this );
        } );
    

    Obviously you need to change the table id from example to whatever your table id is.

    Allan

  • hubonehubone Posts: 13Questions: 4Answers: 0

    I ended up copying whatever existed as the sample and duplicated it to whatever the columns I want, and changed them in staffhtml.php, staff.php. it works now!

    Now I want to add scroll bar because I have so many columns.

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    scrollX. See also the full options list and the examples.

    Allan

  • hubonehubone Posts: 13Questions: 4Answers: 0

    can you tell me the steps?

    I put this code where?
    $('#example').DataTable( {
    ajax: '/api/data',
    deferRender: true,
    scrollY: true,
    scroller: true
    } );

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Have a look inside the Javascript file that Generator creates (table.{name}.js) - you'll find the DataTables initialisation in there.

    Allan

This discussion has been closed.