function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
suneel varmasuneel varma 

lightening :datatable edit cell options dynamically

My task here is.
1.In at lightening:Datatable, i had 4 columns on that 3 columns would be inline edit option(like user will give the values on that cells and save it).
once save it,if the data is present on that cells,i need to restrict the edit option on data presented cells and for other cells to provide edit option.
please give some suggestions or any solutions on this...
thanks
Best Answer chosen by suneel varma
suneel varmasuneel varma
Please refer the below link 
https://salesforce.stackexchange.com/questions/260099/conditionally-enable-edit-in-lightningdatatable/296092#296092
It will fit the above requirement.

There is a way to disable a particular cell in a datatable. Using CSS you can grey out the cell.

[ {label: 'Col 1', fieldName: 'field1', type: 'text', sortable: false},
{label: 'Col 2', fieldName: 'field2', type: 'text', sortable: false},
{label: 'Col 3', fieldName: 'field3', type: 'text', sortable: false, editable: true , **cellAttributes: { class: { fieldName: 'disable' } }**},
];
[ {field1: 't1c1', field2: 't1c2', field3: 't1c3', disable: ''},
{field1: 't2c1', field2: 't2c2', field3: 't3c3', disable: ''},
{field1: 't2c1', field2: 't2c2', field3: 't3c3', disable: 'greyOut'},
];

CSS properties:
-------------------
.THIS .greyOut{
pointer-events: none;
background: #CCC;
color: #333;
border: 1px solid #666
}