Tuesday, January 13, 2015

Javascript DataTables and TN4 error on Sorting

This is just a quick note for myself.  Perhaps it will help others.  Mind you, I feel like this is a workaround, not an actual solution.

I have an ajax sourced DataTable.  (If you're not familliar with these, see: http://datatables.net.  They really are awesome.)

This particular table is struggling with handling the refresh of the table based on clicking a sortable (orderable) column header.

The TN4 error is reported against columns that have a "render" function associated with them.  Removing the render() function removes the problem, but I need those functions or they wouldn't be there.

Adding a "defaultContent" value to the column definition, however, seems to alleviate the issue.  I think the problem is somehow related to the sorting feature clearing the data, then the render function says "Um, you asked for row.clientName, but....there's no data, so there's certainly no "clientName" in the (missing) data."

I have other tables that do NOT have this issue, but this seems to be a workaround.

Now I can remember next time.

- Will Belden
January 13, 2015

No comments: