0

I have a requirement that an editable field in Datatable should be editable on certain conditions for example lets say, i have a field Disable_Action__c which is a formula field , when this field evaluates to false i should be able to edit the field which is there in Datatable.

0

It is not possible to make a field conditionally editable. The way I solved it, was to change the cellattributes conditionally, so I changed the background color to indicate to the user that something is different:

cellAttributes: { class: { fieldName: 'CSS_Class_Quantity__c' } }

But that is not enough, your Javascript code must not take into account the entered data. It would be much easier if editable was conditional, but alas, it isn't at this moment.

  • Hi Sander, thanks a lot for your response i got a workaround for solution for this kind of situation and it got working for me, so posting it here so that others with the same issue willl get benefit out of it. This kind of situation can be resolved by using CSS and a formula field which evaluate your condition for enabling or disable an input field in lightning datatable. In my case i had defined the columns as {label: 'Actual Decision Maker', fieldName: 'Actual_Decision_Maker__c', type: 'text' , editable: true ,cellAttributes: {class: { fieldName: 'Row_Level_Disabled__c' }} }, – Mohammed Aiyaz Aug 7 '20 at 13:17
  • Row_Level_Disabled__c is a formula field which would return a text as enabled Or disabled based on your condition. And in the CSS we need to add below code ".THIS .disabled { position : relative; color: grey; } .THIS .enabled { } .THIS .disabled:after { content:' '; width: 100%; height: 100%; left:0; top: 0; position:absolute; }" Hopefully it would work for others who are facing similar kind of issue. – Mohammed Aiyaz Aug 7 '20 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.