0
我正在使用數據表插件來格式化我的表與我的數據。Datatables和Codeigniter
- 我打電話給我的模型從我的控制器收集所有的數據。
- 我將數據數組發送到視圖文件。
- 我在與調用插件打開常規的HTML表到數據表的表DataTable類視圖啓動一個table標籤。
- 我檢查以驗證是否有在視圖陣列中的數據,然後,如果有我做foreach循環以創建表的行。如果沒有數據,我會迴應一串沒有找到的數據。
我的問題是,當有數據工作正常,但是當沒有數據我收到Requested Unknown Parameter 1 from the data source for row 0
錯誤消息。
我看到其他人都遇到同樣的問題之前,但是所有我看到有解釋說,他們已經使用的DataTable的JSON數據,同時特別是與數據表插件工作的其他職位。
如何防止此錯誤消息的任何想法。
<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>
這是隨主題提供的代碼。
/* 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"
}
});
}
發佈您的代碼,或者我們無法爲您提供幫助! – Technoh
你的數據表代碼在哪裏?調用數據表api /功能的那個?那是給你這個錯誤?你有你正在使用的陣列的樣本嗎?它是一個對象還是帶有對象的數組? – chris
您是否在輸出或控制檯中收到此消息? – Rooster