You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JSON returned when using the row_index_table or column_index_table managers returns data in a label: value format.
This causes issues with the datatables.net API as space characters may appear in the column name e.g. 'exchange rate'. When mapping the columns to a table in datatables, having spaces in the column name causes the data table to raise an exception as can be seen from the fizz buzz column below.
Example of column indexes to the columns found in the data: $(#test).DataTable({ displayLength: 25, search: false, lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, 'All']], orderCellsTop: true, filtering: true, destroy: true, data: data, order: [0, 'desc'], columns: [ {data: 'foo'}, {data: 'bar'}, {data: 'fizz buzz'} ], ...
The exception returned is jquery.js:8264 Uncaught (in promise) TypeError: Cannot convert a Symbol value to a string(…).
There are a few solutions to how we could overcome this.
Ensure each JSON key for a column value has no spaces e.g. "fizz_buzz": 5. Users will have to work out a human friendly name for each column's header programatically.
Ensure each JSON key for a column value has no spaces e.g. "fizz_buzz": 5, but a label field in the nested data that a user can use to dynamically create a header column with a friendly name. e.g. "fizz_buzz": {"label": "Fizz Buzz", "value": 5}. Example at: https://datatables.net/examples/ajax/orthogonal-data.html
Return data using an array of arrays instead of an array of objects. Then the user can either work out what header should map to an array index or maybe FireAnt could pass an array which defines a label for each column, which could then be used by the user to set a human friendly header. Example at: https://datatables.net/examples/ajax/simple.html.
The text was updated successfully, but these errors were encountered:
The JSON returned when using the row_index_table or column_index_table managers returns data in a label: value format.
This causes issues with the datatables.net API as space characters may appear in the column name e.g. 'exchange rate'. When mapping the columns to a table in datatables, having spaces in the column name causes the data table to raise an exception as can be seen from the fizz buzz column below.
Example JSON returned from FireAnt:
{ "draw": 1, "data": [ { "foo": 12.1111 "bar": "1.1", "fizz buzz": 123, "DT_RowId": "row_0" }, { "foo": 12.1111 "bar": "1.1", "fizz buzz": 123, "DT_RowId": "row_1" }, ], "recordsFiltered": 2, "recordsTotal": 2 }
Example of column indexes to the columns found in the data:
$(#test).DataTable({ displayLength: 25, search: false, lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, 'All']], orderCellsTop: true, filtering: true, destroy: true, data: data, order: [0, 'desc'], columns: [ {data: 'foo'}, {data: 'bar'}, {data: 'fizz buzz'} ], ...
The exception returned is
jquery.js:8264 Uncaught (in promise) TypeError: Cannot convert a Symbol value to a string(…)
.There are a few solutions to how we could overcome this.
"fizz_buzz": 5
. Users will have to work out a human friendly name for each column's header programatically."fizz_buzz": 5
, but a label field in the nested data that a user can use to dynamically create a header column with a friendly name. e.g."fizz_buzz": {"label": "Fizz Buzz", "value": 5}
. Example at: https://datatables.net/examples/ajax/orthogonal-data.htmlThe text was updated successfully, but these errors were encountered: