Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82232

Problem accessing row/cell value with Jquery API within Salesforce LWC

$
0
0

I have created a datatable in LWC using jQuery Datatable library. The table shows up correctly. I have added a checkbox in front of each row in the table so that the user can select any rows and can execute some custom action in the server side.

Note - I'm not using lightning-datatable tag to use some sort-search capability of JQuery datatable.

Below is my sample code :

//Query for the table using this.template.querySelector();

const table = this.template.querySelector('.example-table');

//Manually construct the table's headers
const columnHeaders = ['Id', 'Name'];

let columnHeaderHtml = '<thead><tr>';

columnHeaders.forEach(function(header) {
columnHeaderHtml += '<th>' + header + '</th>';
});

columnHeaderHtml += '</tr></thead>';
table.innerHTML = columnHeaderHtml;

//Initialize DataTables

let dataTable = $(table).DataTable();
Populate the Data Table!
Note: 'recordsQueried' is just a list of SOQL'd records.

this.recordsQueried.forEach(function(recordObj) {
tableRow.push('<input class="checkBoxcls" type="checkbox" id="'+recordObj.Id+'"/>');
let sUrl = '/lightning/r/Account/' + recordObj.Id + '/view';
tableRow.push('<a href="' + sUrl + '">' + recordObj.Name + '</a>');
tableRow.push(recordObj.Phone!= undefined ? Phone: '');
....
.....<<more rows added>>
})
oDataTable.draw();

How can I select a particular column and get the specific cell value stored in an array as there could be multiple column selected at the same time.


Viewing all articles
Browse latest Browse all 82232

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>