Closed philbluefox closed 7 years ago
Looks like I have the same problem. When no result found: "Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined"
I encountered this error too but I have found a workaround.. The problem appears to be that both the original DataTables JS library and the Yii2 GridView are trying to provide a message to the user to say the table is empty.
To work around it I have created a class that inherits from DataTables and overridden the renderTableBody function with the following
public function renderTableBody() {
$models = array_values($this->dataProvider->getModels());
if (count($models) === 0) {
return "<tbody>\n</tbody>";
} else {
return parent::renderTableBody();
}
}
This gets rid of the "No results found." message from GridView and just outputs an empty tbody instead.
I've also passed the GridView->emptyText property to clientOptions ->language->emptyTable as this means that datatables renders the same message that GridView would have done.
@adhayward Thanks for the comment. I am busy right now and I am not dedicating to much time for this project. Could you create a pull request? I will merge the change ASAP
A javascript error was displayed in firebug when there is no results found. "TypeError: nTd is undefined
column: i"