Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you use the 'Show the empty text in the table' option and there are no results for the view's query, when template_preprocess_views_view_table($vars) is run in template_preprocess_datatables_view(), it results in the following value for $vars['rows']:
Array
(
[0] => Array
(
[0] =>
)
)
This in turn causes DataTables to throw the error "DataTables warning (table id = 'datatable-1'): Requested unknown parameter '1' from the data source for row 0". This is the result of table rendering the following:
<tbody>
<tr class="views-row-first views-row-last">
<td class="views-field views-field-">
</td>
</tr>
</tbody>
The $vars['rows'] array should be an empty array if there is no data to display.
Comment | File | Size | Author |
---|---|---|---|
#1 | datatables-show_empty_table_error-2514094-1.patch | 600 bytes | zifiniti |
Comments
Comment #1
zifiniti CreditAttribution: zifiniti as a volunteer commentedPatch attached.
Comment #2
samstamport CreditAttribution: samstamport commentedI am getting this error, but 'Show the empty text in the table' option is not checked. I have a table I'm using in a view for the Project Management (PM) module. I have projects without tasks and projects with tasks. Could this be a similar problem? Is there a fix?
Update: I installed the dev version of datatables and the problem went away.
Comment #3
zifiniti CreditAttribution: zifiniti as a volunteer commentedComment #4
dqdWe are on 7.x 2.x and D8 now 3 years later ... so I would say this issue can be closed for now and reopened with changed code version option if somebody wants to report and patch it for 2.x or D8, if still required.