DataTables / Responsive

Responsive extension for DataTables, providing support for complex tables on all device screen sizes
Other
148 stars 86 forks source link

Empty column values are showing as `null` when in the collapsed menu #105

Closed jeffblake closed 6 years ago

jeffblake commented 6 years ago

My setup is using serverSide.

The attribute in question is provided in ticket_fields.id.value json where id is replaced by the field ID.

In normal view, if the column value is empty, it works as expected: the td cell is blank. However, if the column becomes hidden, the value changes to null, when I expect it to be blank, like in the non-responsive view.

DataTables commented 6 years ago

Could you give me a link to a page showing the issue please? Trying it here shows an empty string rather than null in the responsive row.

jeffblake commented 6 years ago

Sorry I can't send a link to one.

The reason that demo works I think is because it's not using a nested key from the server.

DataTables commented 6 years ago

I've updated the example to use nested data and it still appears to be okay.

jeffblake commented 6 years ago

I think I've diagnosed the error better:

Sequence of events

  1. $.fn.dataTable.ext.errMode = 'none' . -->> resulted in above silent bug
  2. Added Bugsnag error tracking library. I think this re-surfaced the error that was silenced by the setting in step 1. I was getting a bunch of these errors:
screen shot 2018-02-02 at 8 47 17 am

DataTables warning: table id=event_tickets_table-67102 - Requested unknown parameter 'ticket_fields.1852' for row 6, column 16. For more information about this error, please see http://datatables.net/tn/4

This is because the ticket_fields hash (not array) is dynamic. Some rows may have fields 1852, some may not. For database performance reasons, the server omits any fields a particular row/ticket doesn't have.

  1. Then I added the defaultContent property to every column definition, and everything is now working.

To recap, this may be a feature, not a bug, but you know best.

The reason I set errMode to none, is because I wanted to silence ajax (server) errors, as I was already handling them with this:

$(document).ajaxError (event, jqxhr, settings, thrownError) ->
  handle_ajax_error(event, jqxhr)

So it looks like by using the bugsnag library, I can still track errors by setting errMode to none, which is great, but I am wondering if there is a way to set errMode to throw for anything EXCEPT ajax errors?

DataTables commented 6 years ago

Yes - DataTables doesn't just treat null or undefined as an empty string intentionally. It might be that you want to set it to be "No data" or similar (which null often means rather than an empty string) - so DataTables forces you to be explicit about it.

Currently no - there isn't a way to selectively set errorMode for specific errors. You could use it as a function and then do the selection yourself.

Going to close this as DataTables appears to be working as designed.