Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a null/empty column in the Datatables front-end breaks search and ordering in the REST API #59

Closed
viseshrp opened this issue Oct 11, 2019 · 0 comments · Fixed by #60

Comments

@viseshrp
Copy link
Contributor

viseshrp commented Oct 11, 2019

Sometimes I use datatables with a column of checkboxes in the front-end for selection. During a request, this column is set as empty strings. When drf-datatables encounters an empty string, it breaks out and returns no fields which in turn breaks search and ordering.

Example: A dummy column like this:

{
                "data": null,
                "defaultContent": '',
                'searchable': false,
                'orderable': false,
                'className': 'dt-body-center',
                'render': function (data, type, row, meta) {
                        return `<input type="checkbox" class="item_select_checkbox"/>`;
                    }
                }
            }

will result in params like:

'format': ['datatables'], 'draw': ['6'], 'columns[0][data]': [''], 'columns[0][name]': [''], 'columns[0][searchable]': ['false'], 'columns[0][orderable]': ['false'], 'columns
[0][search][value]': [''], 'columns[0][search][regex]': ['false'],

Because of this line: any column like the above will result in an empty list of fields which will break search and ordering.

@viseshrp viseshrp changed the title Using a null/empty column in the Datatables front-end breaks search and ordering in the API Using a null/empty column in the Datatables front-end breaks search and ordering in the REST API Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant