restrict inline editing to specific fields

restrict inline editing to specific fields

crush123crush123 Posts: 417Questions: 126Answers: 18

I have implemented inline editor using the example here

https://editor.datatables.net/examples/inline-editing/simple.html

Is it possible to restrict inline editing to a specific field, but maintain editing of all fields when the editor modal is visible ?

This question has accepted answers - jump to:

Answers

  • mRendermRender Posts: 151Questions: 26Answers: 13
    Answer ✓

    Do you know what field it is? Is it going to change dynamically? Do you want to be able to make the editor also work on the inline field?

    It is possible, the way you do it just changes depending on the questions above.

    You would essentially change this code:

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

    To function based on a click of a specific column or specific row or whatever you're looking to do.

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    Thx for the reply.

    The field name will not change dynamically,

    In this instance, I am retrieving my columns from an ajax object, so I have a field called 'ChequeNumber' which I want to use in my editor instance and inline, but it is the only field I want to be able to edit inline

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    I would suggest adding the class editable to the columns you want to be inline editable and then modifying the selector as Modgility suggested to match on that (rather than the :not(...) that you are currently using.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    Thanks guys, I was looking at it from the wrong perspective.

    What I did was restrict which column would enable the editor

    eg

    $('#example').on( 'click', 'tbody td:nth-child(9)', function (e) {...
    
This discussion has been closed.