How to get the column value from the data table into variable
How to get the column value from the data table into variable
rakeshkumar123
Posts: 11Questions: 5Answers: 0
startRender: function ( rows, group, level ) {
if (level === 0) {
return $('<tr/>')
.append( '<td colspan="6" style="background-color:#e8e8e8;font-weight: bold;letter-spacing:1px; "><span style="margin-right:10px; margin-top:2px; display:inline-block; position: relative;top: 2px;">SITE : '+group+' </span></td>' );
}
else
{
var site_no = 'AD540';
return $('<tr/>')
.append( '<td colspan="6" style="background-color:#e8e8e8;font-weight: bold;letter-spacing:1px; "><span style="margin-right:10px; margin-top:2px; display:inline-block; position: relative;top: 2px;">SUBMISSION DATE : '+group+' / </span><a href="view_submissions.php?submissions_dt='+group+'" class="btn btn-primary btn-xs" style="color:#ffffff; font-weight:normal" ><i class="fa fa-eye"></i> VIEW</a> <a href="view_submissions_pdf.php?submissions_dt='+group+'&site_no='+site_no+'" class="btn btn-primary btn-xs" style="font-weight:normal" target="_blank" ><i class="fa fa-file-pdf-o"></i> PDF</a></td>' );
}
},
In this above code want to have var site_no one of the column value dynamically now I have added static value to use in a href
This discussion has been closed.
Answers
This is to select a single cell from a data table:
https://datatables.net/reference/api/cell()
https://datatables.net/reference/api/cell().data()
And this is to select an entire column:
https://datatables.net/reference/api/column()
https://datatables.net/reference/api/column().data()
This is to loop through all columns:
https://datatables.net/reference/api/columns().every()
And this to loop through all rows of a data table:
https://datatables.net/reference/api/rows().every()
Didn't see much on the usage of "cell()". Here is an example from my own coding:
@rf1234 Thank you but in my case I want to add var site_no = [columnname];
How i can achieve this ?
https://datatables.net/reference/api/column().name()
The columns().name() API is not available until Datatables 2.0. The docs have:
In my second to last post, in thie [thread[(https://datatables.net/forums/discussion/60755), look at the example I have using
columns.header()
to get the column name.Kevin
Hi Kevin, many thanks!
And I found something in my code retrieving a column name from the header: