You need to sign in to do that
Don't have an account?
picklist in inline editing of lightning datatable
Dear Team ,
Greetings !!!
I am trying to integrate picklist in inline functionality of lightning datatable . Type column is picklist in below code . My controller code are as follows :
({
doInit : function(component, event, helper) {
component.set('v.mycolumns', [
{label: 'Account Name', fieldName: 'Name', type: 'text', editable: true, initialWidth: 750},
{label: 'Phone', fieldName: 'Phone', type: 'phone', editable: true},
{label: 'Rating', fieldName: 'Rating', type: 'text', editable: true},
{label: 'Number Of Employees', fieldName: 'NumberOfEmployees', type: 'number', editable: true},
{label: 'Type', fieldName: 'Type', type: 'List', editable: true}
]);
var action = component.get("c.details");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var res = response.getReturnValue();
component.set("v.mydata", res);
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
}
else {
console.log(response.getReturnValue());
}
}
});
$A.enqueueAction(action);
},
saveTable : function(component, event, helper){
//var data = component.get("v.mydata");
var draftValues = event.getParam('draftValues');
var action = component.get("c.updateDetails");
action.setParams({lstForm : draftValues});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var res = response.getReturnValue();
$A.get('e.force:refreshView').fire();
alert('Updated Successfully...');
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
}
else {
console.log(response.getReturnValue());
}
}
});
$A.enqueueAction(action);
}
})
Kindly suggest some solution in order i am able to perform this functionality .
Thanks & Regards
Sachin Bhalerao
Greetings !!!
I am trying to integrate picklist in inline functionality of lightning datatable . Type column is picklist in below code . My controller code are as follows :
({
doInit : function(component, event, helper) {
component.set('v.mycolumns', [
{label: 'Account Name', fieldName: 'Name', type: 'text', editable: true, initialWidth: 750},
{label: 'Phone', fieldName: 'Phone', type: 'phone', editable: true},
{label: 'Rating', fieldName: 'Rating', type: 'text', editable: true},
{label: 'Number Of Employees', fieldName: 'NumberOfEmployees', type: 'number', editable: true},
{label: 'Type', fieldName: 'Type', type: 'List', editable: true}
]);
var action = component.get("c.details");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var res = response.getReturnValue();
component.set("v.mydata", res);
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
}
else {
console.log(response.getReturnValue());
}
}
});
$A.enqueueAction(action);
},
saveTable : function(component, event, helper){
//var data = component.get("v.mydata");
var draftValues = event.getParam('draftValues');
var action = component.get("c.updateDetails");
action.setParams({lstForm : draftValues});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var res = response.getReturnValue();
$A.get('e.force:refreshView').fire();
alert('Updated Successfully...');
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
}
else {
console.log(response.getReturnValue());
}
}
});
$A.enqueueAction(action);
}
})
Kindly suggest some solution in order i am able to perform this functionality .
Thanks & Regards
Sachin Bhalerao
Greetings to you!
In lightning:datatable picklist will not list down dropdown values in Inline Edit mode. There's an idea which is active on the success community with a similar discussion for which you can upvote so that it gets available in the future.
https://success.salesforce.com/ideaView?id=0873A000000PZJ4QAO
As a workaround, change the type of the picklist column from picklist to button. On button click, open a modal which fetches and displays the picklist values. Or you can use a custom SLDS data table.
Please refer to the below link which might help you further with the above requirement.
http://www.sfdcpanda.com/lightning-datatable-with-picklist-select-powered-in-edit-mode/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
In lightning:datatable picklist will not list down dropdown values in Inline Edit mode. There's an idea which is active on the success community with a similar discussion for which you can upvote so that it gets available in the future.
https://success.salesforce.com/ideaView?id=0873A000000PZJ4QAO
As a workaround, change the type of the picklist column from picklist to button. On button click, open a modal which fetches and displays the picklist values. Or you can use a custom SLDS data table.
Please refer to the below link which might help you further with the above requirement.
http://www.sfdcpanda.com/lightning-datatable-with-picklist-select-powered-in-edit-mode/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
https://vkambham.blogspot.com/2020/01/picklist-supported-lightning-editable-datatable.html
https://blog.lkatney.com/2019/11/13/picklist-in-lightning-datatable/
https://www.playg.app/play/picklist-in-lightning-datatable
@Venky, I hope this is fine with you.
Creating Custom Data Types section on page https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation.
To know more how to do this pleaes visit following
https://inevitableyogendra.blogspot.com/2021/04/picklist-in-lightning-datatable.html
I have also created a package
https://login.salesforce.com/packaging/installPackage.apexp?p0=04t0K000000wUik
you can install this make it work.