Add New Record in Data Table not editable

Hi, I'm new here, can anyone can help me with my problem? When I click the Add new record, the dropdown list in column Item is disabled but the rest of the rows are enabled. See image below.
image

image

I've already tried the Set fields based on other fields example with no luck.

Here is my code.

var actions = {}; //array "actions"
fd.rendered(function() {
var dt = fd.control('BoardingTask');

dt.columns[1].editable = function() { return false };

dt.$on('change', function(valx) {
    if (valx) {
        for (var i =0; i < valx.length; i++) {
            valx[i].TaskDescription = actions[valx[i].TaskName] || null;
        }
        dt.widget.refresh();
        dt.saveState(valx);
    }
});

});

Hope you could help.

Hello @Bert,

Welcome to Plumsail Community!

We recently updated the functionality of the Data Table control and have not yet updated the code examples in the documentation. Please try out this code:

var merch = {};
merch['Baseball cap'] = 9.99;
merch['T-shirt'] = 19.99;
merch['Key chain'] = 4.99;

fd.rendered(function () {
    var dt = fd.control('DataTable1');

    const unitPriceColumn = dt.columns.find(c => c.field === 'UnitPrice');
    unitPriceColumn.editable = () => false;

    dt.$on('change', function (value) {
        if (value) {
            for (var i = 0; i < value.length; i++) {
                value[i].set('UnitPrice', merch[value[i].Product] || 0);
            }
        }
    });
});
1 Like

Hi @mnikitina,

Thank you so much. It works fine but the Data Table won't get updated. If I add the dt.widget.refresh(), the dropdown list in column Item is disabled just like before.

The column Action/Activities will get refreshed if it receives a focus but not disabled. If disabled, the dt.widget.refresh() will do but the dropdown list in column will be disabled.

@Bert,

Using the code I've shared you don't need the dt.widget.refresh() line.

Please share the code you are using and if possible the link to your form. You can DM me the link.

1 Like