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
Siva Reddy 257Siva Reddy 257 

Wrapper class in LWC

Hi,

Through LWC I am able to display list of records  along with check box in custom table .
Issue is how can I pass only selected records to apex class from lwc like how we pass  from aura component to apex class.

Please someone guide me.
AbhishekAbhishek (Salesforce Developers) 
A wrapper or container class is a class, a data structure, or an abstract data type which contains different objects or collection of objects as its members


Try the code snippet as mentioned in the below developer discussion,
https://salesforce.stackexchange.com/questions/255943/how-to-use-wrapper-class-in-lwc


For further reference you can check the below,
https://www.sfdcpoint.com/salesforce/wrapper-class-in-lwc/#:~:text=A%20wrapper%20or%20container%20class,of%20objects%20as%20its%20members.


If it helps mark this the best answer.
ravi soniravi soni
hi shiva,
In your Lwc Js file  copy & paste this following line.
import testClassMethodfrom '@salesforce/apex/testClass.testClassMethod';
var storeListStringData = [];

/*Put all selected data Id in this storeListStringData variable and parse it into apex like following*/
//Apex class

Public class testClass{
  public static void testClassMethod(list<string> lstString){
//writer your code
//And in apex class you can  query of your selected data like following
List<Account> lstAccount = [SELECT Id,name From Account Where Id In : lstString];
}
}

//how to call apex method from lwc
testClassMethod({'lstString' : ' storeListStringData '}).then(result => {
console.log(result);
}).catch(error => {
console.log(error);
}):

let me know if it helps you and marking it as best.
Thank You
 
Siva Reddy 257Siva Reddy 257
Hi Abhishek ,

The links which you gave alraedy i have seen  , In that link we have code to display records from wrapper class that already I am doing .

I am looking for how to pass the  wrapper class data  to apex class I hope you understand my requirement.
 
Siva Reddy 257Siva Reddy 257
Hi Veer soni,

I will try with your code snippet and will let you know.