Select field when getting data from an ajax request
Select field when getting data from an ajax request
![vtcpe12](https://secure.gravatar.com/avatar/813b4e10e42a7eb85d26a9936ffdfe3a/?default=https%3A%2F%2Fvanillicon.com%2F813b4e10e42a7eb85d26a9936ffdfe3a_200.png&rating=g&size=120)
Hi,
I'm currently getting data from an ajax request and it is working great. The problem is that I need to add a select field to each row. Is there a method to do so? The select field will be dynamic but will not change from row to row, it is dependent on another parameter that I pass to the ajax request. I have included my initialization of the datatable, it is pretty basic:
const datatable = $('#maint_docs').DataTable({
'ajax': url,
'rowCallback': function(row, data, index) {
const color = '#'+data[8];
$(row).find('td:eq(7)').css('background-color', color);
},
'columnDefs': [
{
'targets': [8],
'visible': false,
'searchable': false
},
{
'targets': [9],
'searchable': false,
'sortable': false
}
]
});
Thanks in advance.
This discussion has been closed.
Answers
Not sure I totally understand what you are trying to do. The Select extension is the easiest way to implement a column for row selection. Take a look through the examples to see if they help:
https://datatables.net/extensions/select/examples/
Please provide more details. Its not clear to me what your goal is.
Kevin