Render column as a link
Render column as a link

I am generating a datatable using dynamic columns. I need to render one of the columns as a link using the render property. Below error is thrown while trying to achieve it.
DataTables warning: table id=WorkLoadGrid - Requested unknown parameter '' for row 0, column 0
code snippet:
WorkLoadHeadings.Render = "function ( data, type, row, meta ) { return '<a href=' + data + '>Download</a>'; } ";
script:
$.each(result.WorkLoadHeadings, function (i, value) {
column.push({ "data": value.ColumnName, "title": value.ColumnDescription, "name": value.ColumnName, "Width": 4, "render": value.Render });
});
$('#WorkLoadGrid').DataTable({
bLengthChange: false,
bPaginate: false,
bInfo: false,
scrollY: "370px",
scrollX: true,
filter: false,
paging: false,
data: result.GridDataList,
columns: column,
});
This discussion has been closed.
Answers
Hi @Arul27 ,
Take a look at the fourth example of
columns.render
, it's showing how to generate a link,Cheers,
Colin
Hi Colin,
Thanks for the response. I am also following the code snippet given in that example but am getting the error below.
DataTables warning: table id=WorkLoadGrid - Requested unknown parameter '' for row 0, column 0
Thanks,
Arul
You are using
data: result.GridDataList,
. What does data: result.GridDataList contain? Did you follow the troubleshooting steps provided in the alert error link?https://datatables.net/manual/tech-notes/4
Kevin
result.GridDataList is the array collection which will have the required data for the table.
Can you post an example of the data in result.GridDataList?
And does the structure of result.GridDataList match the structure you are building for the columns? Maybe you can post and example of the resulting
column
variable.Kevin
Below is the values assigned in result,GridDataList . Trying to render the values in column ContractLastFirstName as a link button.
