NullRefExcep / yii2-datatables

Yii2 Widget for DataTables jQuery plug-in
http://www.datatables.net/
MIT License
72 stars 46 forks source link

filter with multiple tables in one page #54

Open nrob81 opened 5 years ago

nrob81 commented 5 years ago

Hello,

I have multiple tables in one page and my row filtering won't works. Wth one table, its working.

the error i get in console is: TypeError: preSearch[column] is undefined jquery.dataTables.js:9072:6

ZAYEC77 commented 5 years ago

hello @nrob81 please provide part of source code where you call datatables widgets

nrob81 commented 5 years ago
foreach ($content['tables'] as $tableId => $table) {

foreach ($table['columns'] as $key) {
    $column = [
        'data' => $key,
        'title' => $model->getAttributeLabel($key),
    ];
    $columns[] = $column;
}

echo \nullref\datatable\DataTable::widget([
    'data' => $table['data'],
    'columns' => $columns,
    'paging' => false,
    'ordering' => false,
    'info' => false,
    'withColumnFilter' => true,                                 
    'id' => $tableId,
]);

}
ZAYEC77 commented 5 years ago

Thanks, I'll try to reproduce it It will be useful if you could add full stack trace of JS error from console

nrob81 commented 5 years ago
TypeError: preSearch[column] is undefined[Learn More] 3 jquery.dataTables.js:9072:6
    <anonymous> http://r.local/assets/4a415d84/js/jquery.dataTables.js:9072:6
    iterator http://r.local/assets/4a415d84/js/jquery.dataTables.js:7057:14
    <anonymous> http://r.local/assets/4a415d84/js/jquery.dataTables.js:9067:11
    _api_registerPlural/< http://r.local/assets/4a415d84/js/jquery.dataTables.js:7311:14
    methodScoping/< http://r.local/assets/4a415d84/js/jquery.dataTables.js:7195:16
    <anonymous> http://r.local/kontrolny/default/index:870:17
    dispatch http://r.local/assets/771ef92b/jquery.js:4736:16
    add/elemData.handle http://r.local/assets/771ef92b/jquery.js:4549:6
ZAYEC77 commented 5 years ago

Hey @nrob81 Sorry, but I can't reproduce this kind of issue with last dev-master version. Also, I found another issue connected with multiple tables with filters on one page. Please, check my examples here. If you still have an issue, please contact me, we try to resolve it individually.