Disable DataTable field on change

Hello,
I have a DataTable that auto populates a column with the current users name. I'd like that field/column to become disabled (or read only) once it is auto populated. Here's my current code for the Data Table:

fd.spRendered(function() {

fd.control('DataTable1').$on('change',

function(e) {

    var username = _spPageContextInfo.userDisplayName;

    fd.control('DataTable1').value[0].Column4 = username;

});

});

Hello @ParAvion,

To disable a column in a DataTable control, use the following code:

fd.control('DataTable0').columns[0].editable = function(){return false};

Where 0 in columns[0] is the column index.

So the code will be as below, just check that the column index is correct.


fd.spRendered(function() {

fd.control('DataTable1').$on('change',

function(e) {

    var username = _spPageContextInfo.userDisplayName;

    fd.control('DataTable1').value[0].Column4 = username;

    fd.control('DataTable1').columns[3].editable = function(){return false};

});
});

Please find more information about DataTable control in our documentation here.