[英]How to update specific inputText in dataTable to be enabled or disabled based on rowSelect event
[英]How to disabled a button on lightning datatable based on field value?
我想禁用基於 boolean 字段的閃電數據表上的按鈕,我來到了這個解決方案:
const columns = [
{ label: 'Client', type:'button',
typeAttributes: {
label: 'Client',
disabled: {fieldName: 'Client__c' }
} }
];
問題是,我需要在為真時使其可見,但實際上相反,我搜索啟用的屬性或嘗試這樣的事情:
Client__c == true ? false : true;
但它不起作用..我也在這里嘗試這個解決方案
this.tableData = result.data.map((value) => ({ ...value, clientDisabled: ('Client__c' == true) ? false : true }));
和專欄:
const columns = [
{ label: 'Client', type:'button',
typeAttributes: {
label: 'Client',
disabled: {fieldName: 'clientDisabled' }
} }
];
此外,不起作用,所有按鈕都被禁用。
另外,我想在禁用時添加 - (並且字段 = false),如下所示:
'Client__c' == true
總是 false; 您正在比較兩個永遠不會相等的文字值。 您將希望使用記錄中的數據:
this.tableData = result.data.map((record) => ({ ...record, clientDisabled: !record.Client__c }));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.