disabling editing of a column

disabling editing of a column

javismilesjavismiles Posts: 205Questions: 38Answers: 3

Good day, In my tables I dont want to allow people to edit the userid field because its auto-increment and that would cause problems. I tried not to include it in the table but that gives trouble, so next option is to make it non-editable or invisible,
how can I make a column non-editable or invisible?
thanks a lot

Replies

  • javismilesjavismiles Posts: 205Questions: 38Answers: 3

    Thank you very much for your help, I still couldnt make it fully work,
    look, Im declaring multiple editors dynamically, if i use disable() , it works, it disables all the fields, but if i try to do what i need to do, to disable just 2 specific ones:

      $.map(obj.fields, function(obj, index) {
           fieldobj[index]  = { 'label':obj.i+":", 'name':obj.i };        
           colobj[index+1]  = { 'data':obj.i };           
        });
    
        eArray[index] = new $.fn.dataTable.Editor( {
        "ajax": {"url": "servercustom1.php","type": "POST","data": {"etype": obj.table}},
        table: "#"+obj.table,
        fields: fieldobj});
    
        eArray[index].disable( ['userid'] );
    

    ...................... etc, etc, etc

    then it gives error:
    "Uncaught TypeError: Cannot read property 'disable' of undefined"

    its like it cannot recognize that specific field, which is absurd, im declaring them in the statement before, its that fieldobj object that contains them

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    I can only sure that there isn't a field called userid in the fields array (perhaps it is userId or userID?).

    However, I don't understand why you need to include it at all. If you look at this example you'll be able to see that there isn't a field explicitly defined for the id column.

    Can you link to a test case showing that issue please.

    Allan

This discussion has been closed.