difference in the number of columns between creation and edition

difference in the number of columns between creation and edition

SWATswatSWATswat Posts: 83Questions: 0Answers: 0

Hello,

I have for example 10 columns to display and I display them all.
Creation :
I would like during the creation of a line to fill these 10 columns with Datatables Editor.

BUT

Editing :
I wish I could edit only 4 of the 10 columns.

Is it possible to have this difference between creation and edition?
If yes how please?

By thanking you.

Replies

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    Use the fields configuration option in the Editor initialization to define the specific fields you want to edit. See the fields.data docs for more info.

    Kevin

  • SWATswatSWATswat Posts: 83Questions: 0Answers: 0

    Thank you kthorngren for your answer.
    Unfortunately I'm not a developer and I don't understand the example, do you have a simpler example for me to understand please?

    Thanking you.

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    This example has four columns with two of them being editable.
    http://live.datatables.net/guwafemu/94/edit

    Kevin

  • SWATswatSWATswat Posts: 83Questions: 0Answers: 0

    I just saw the example and it's exactly like my problem:
    Edit: 2 columns AND Create: 2 columns.

    I would like to:
    Edit: 2 columns. And Create: 4 columns.

    Is it possible?

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    Sorry, misunderstood your question. Allan provides a few options in this thread.

    Kevin

  • SWATswatSWATswat Posts: 83Questions: 0Answers: 0

    Thanks. Sounds like what I'm looking for,
    to your knowledge is there an example online please?

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    Probably the easiest is to use two instances like this:
    http://live.datatables.net/guwafemu/95/edit

    Kevin

  • SWATswatSWATswat Posts: 83Questions: 0Answers: 0

    It's perfect,

    Thank you very much.

  • SWATswatSWATswat Posts: 83Questions: 0Answers: 0
    edited August 2020

    I made the modification and it's working fine.

    But with the "inline Editor" version the cell modification is not possible anymore, how to fix this problem please?

    Thanks

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    But with the "inline Editor" version the cell modification is not possible anymore, how to fix this problem please?

    Its hard to say without seeing what you have. You should be able to edit the fields you have defined with the editor instance. You have something similar to this to define the inline editor.
    ``js
    // Activate an inline edit on click of a table cell
    $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
    editor.inline( this );
    } );
    ```

    The editor.inline( this ); will use the editor instance you defined in the editor (or whatever variable you have).

    Look in the browser's console for errors.

    Kevin

  • SWATswatSWATswat Posts: 83Questions: 0Answers: 0

    Thanks for the lead, I replaced this

    editor.inline( this, {...
    

    By

    editorEdit.inline( this, {...
    

    Thanks you.

This discussion has been closed.