You need to sign in to do that
Don't have an account?
Anil Bolisetty 2
lightning table custom filters
Hello,
I am using lightning:datatble to display some list i have a requirement to use filters like start date end date and 2 picklist values ,user can choose any combination to update the list can any one suggest better design ?
I am using lightning:datatble to display some list i have a requirement to use filters like start date end date and 2 picklist values ,user can choose any combination to update the list can any one suggest better design ?
Greetings to you!
Please refer to the below links which might help you further with the above requirement.
https://salesforce.stackexchange.com/questions/230027/how-to-change-data-in-lightning-datatable-based-upon-a-dropdown-select-filter
https://salesforce.stackexchange.com/questions/219619/search-functionality-in-lightningdatatable
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
Thanks,
Karthik
Did it in my org. if you want it contact me on rkreddy.sfdx at gmail.com
I would recomment you to use the custom search bar in which you can enter any value if it is your dates value or any picklist values and put a search logic in the javascipt itself instead of going to the backend for this and inserting WHERE filters in the query as it is time consuming.
Something like this:-
if (searchString) {
for (var i = 0; i < allRecords.length; i++) {
var allRecord = allRecords[i];
var isFound = false;
for (var key in allRecord) {
if (allRecord.hasOwnProperty(key)) {
/*console.log('record ' + key + ': ' + ((allRecord[key]).toString()).toLowerCase());
console.log('searchString: ' + searchString.toLowerCase());
console.log('value: ' + (((allRecord[key]).toString()).toLowerCase()).indexOf(searchString.toLowerCase()));*/
if ((((allRecord[key]).toString()).toLowerCase()).indexOf(searchString.toLowerCase()) > -1 && displayedFields.indexOf(key) > -1) {
//console.log(allRecord);
isFound = true;
}
}
}
if (isFound) {
//console.log(allRecord);
filteredRecords.push(allRecord);
}
}
//console.log(filteredRecords);
c.set('v.filteredRecords', filteredRecords);
} else {
c.set('v.filteredRecords', allRecords);
}
Thanks,
Rishabh Bansal