Hello i'm using Ajax Methode to fill a DataTable i have tested my Web API and it's working correctly but i keep getting this message No data available in table
jQuery Code :
// DataTables
var table = $("#table").DataTable({
ajax: {
url: "/api/picklist/getpicklist",
dataSrc:"",
},
columns: [
{
data:"numero_picklist"
},
{
data:"PFIN"
}
]
});
HTML Table :
<table id="table" class="table table-bordered table-hover table-responsive table-striped">
<thead>
<tr>
<th>Numéro picklist</th>
</tr>
</thead>
</table>
web API :
// GET /api/picklist
public IEnumerable<PicklistDto> GetPicklist()
{
return _context.Dimension_picklist.ToList().Select(Mapper.Map<Dimension_picklist,PicklistDto>);
}
Web API Test : enter image description here
Here are some things you can do to help you debug. My guess is that your data is not where you thing it is on your json objejct.
First you need learn sractch of data table & its parameter. On the ajax its send the some parameter to target method to fetch record and filterning. i've used DTParameters which contail the param.
Here is ActionMethod
index.chsml datatable script
Create the modal class 'DatatablesViewModel' save it , import to your controller.
For more detail you can visit this site visit this