I'm using the datatables plugin to format my tables with my data.
- I make the call to my model from my controller to gather all the data.
- I send the data array to the view file.
- I start a table tag in my view with the datatable class which calls the plugin to turn the regular html table into a datatables table.
- I check to verify that there is data in the array in the view and then if there is I do a foreach loop to create the table rows. If there is not data then I echo out a string of no data found.
My issue is when there is data it works fine however when there is not data I receive Requested Unknown Parameter 1 from the data source for row 0
error message.
I've seen others that have come across this same issue before however all the other posts I have seen have explained that they have used the datatables json data while specifically working with the datatables plugin.
Any ideas on how to prevent this error message from displaying.
<table class="dynamicTable table table-striped table-bordered table-condensed">
<thead>
<tr>
<th style="width: 1%;" class="uniformjs" id="checkboxth"><input type="checkbox" /></th>
<th class="center">ID</th>
<th>Name</th>
<th class="center">Date</th>
<th class="center" id="created_updated"></th>
<th class="right" id="actions">Actions</th>
</tr>
</thead>
<tbody>
<?php
//vardump($themes);
if (isset($themes) && is_array($themes))
{
foreach ($themes AS $theme)
{
echo '<tr class="selectable">';
echo '<td class="center uniformjs"><input type="checkbox" /></td>';
echo '<td class="center">' . $theme->id . '</td>';
echo '<td>' . $theme->name . '</td>';
if ($theme->updated_at != '0000-00-00 00:00:00')
{
echo '<td class="center" style="width: 80px;">' . date('d M Y', strtotime($theme->created_at)) . '</td>';
echo '<td class="center" style="width: 80px;"><span class="label label-block label-inverse">updated</span></td>';
}
else
{
echo '<td class="center" style="width: 80px;">' . date('d M Y', strtotime($theme->created_at)) . '</td>';
echo '<td class="center" style="width: 80px;"><span class="label label-block label-important">created</span></td>';
}
echo '<td class="center" style="width: 60px;">';
echo '<a href="' . base_url() . 'themes/edit/' . $theme->id . '" class="btn-action glyphicons pencil btn-success"><i></i></a>';
echo '<a href="' . base_url() . 'themes/delete/' . $theme->id . '" class="btn-action glyphicons remove_2 btn-danger"><i></i></a>';
echo '</td>';
echo '</tr>';
}
}
else
{
echo '<tr>';
echo '<td class="center" colspan="7">There are no themes. Select Add a New Theme.</td>';
echo '</tr>';
}
?>
</tbody>
</table>
This is the code that came with the theme.
/* DataTables */
if ($('.dynamicTable').size() > 0)
{
$('.dynamicTable').dataTable({
"sPaginationType": "bootstrap",
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
}
});
}