disable inline editing on specific columns with ajax

disable inline editing on specific columns with ajax

dunkinjoesdunkinjoes Posts: 3Questions: 1Answers: 0
edited August 2020 in Free community support

I am new with ajax, and I cannot figure out how to disable inline editing on column 0 and 2 on my datatable, can anyone help?

thanks

$(document).ready(function(){
  
  fetch_data();

//fetch record from inventory
  function fetch_data()
  {
   var dataTable = $('#sample_data').DataTable({
    "processing" : true,
    "serverSide" : true,
    "order" : [],
    "ajax" : {
     url:"AddInventoryFetch.php",
     type:"POST"   
    },
    "columnDefs":[
    {
      "targets":[0, 2],
      "orderable":false,
    },
    ]
   });
  }
});

This question has an accepted answers - jump to answer

Answers

  • dunkinjoesdunkinjoes Posts: 3Questions: 1Answers: 0
    edited August 2020

    is there a similar way like

    "columnDefs":[
    {
    "targets":[0, 2],
    "orderable":false,
    },
    ]
    

    except it applies to Column editable?

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    Answer ✓

    This example shows how to enable inline editing on specific columns:
    https://editor.datatables.net/examples/inline-editing/simple.html

    The code to pay attention to is this:

        // Activate an inline edit on click of a table cell
        $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
            editor.inline( this );
        } );
    

    You can add a class, using columns.className to the columns you don't want inline editing enabled on and add that to the not() selector.

    Kevin

  • dunkinjoesdunkinjoes Posts: 3Questions: 1Answers: 0

    Thank you

This discussion has been closed.