DataTables 1.9.3

DataTables 1.9.3

allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
edited August 2012 in Announcements
Hello all,

I'm excited to announce that DataTables 1.9.3 is now available. Although this is a minor release of DataTables it is none-the-less important for the bug fixes that it includes and also one important new feature - mRender .

mRender is the compliment of the mData option (renamed in this release from mDataProp - this is a backwards compatible change! You can still use mDataProp, the reason for the renaming is for naming consistency and flexibility). mRender will be the subject of a blog post shortly, so I'll only summarise its abilities here, but basically it can replace fnRender with something that has far more ability.

mData, as described in this blog post, http://datatables.net/blog/Orthogonal_data , can be used to provide DataTables with different data for each cell data type, however, it has the added complication of needed to work with setting the data value - sometimes this can be useful, but often it just requires extra code. mRender does not need to consider the setting of data, just returning the data required for each type. This can take the form of a string or a function, just like mData and will use the value pointed to by mData and its base value (although it does have access to the full data source object if needed).

In addition to this the mData / mRender syntax as been expanded to include array notation for dealing with nested arrays. For example, if you had a JSON data source which looks like:

[code]
{
"name": "Allan",
"access": [
{ "id": 3, "name": "Printers" },
{ "id": 8, "name": "Scanner" },
{ "id": 6, "name": "Lab" }
]
}
[/code]

Previously, if you had wanted to simply put the `name` parameter from `access` into the DataTable, you would need to have created a mData function that would loop over the array, plucking out the parameter you want. Now however, what you can do is simply, for the column definition:

[code]
{
"mData": "access",
"mRender": "[, ].name"
}
[/code]

Note the mRender syntax - the square brackets indicate an array that will be traversed over (the `access` array, from on mData), while the `, ` in-between the two square brackets tells DataTables to concatenate the values found from the array with those two characters (i.e. we get a comma separated list) and finally the `.name` part picks up the `name` parameter from the objects in the array. Equally, you could just use an array of strings rather than an array of objects and not use objects in the `access` array.

This is all fairly deep stuff in DataTables, but this really enhances the abilities of DataTables and is why I'm excited about this 1.9.3 release. The power of the options presented by mData / mRender and the new array syntax will hopefully become more apparent with the release of Editor 1.2 shortly, which makes extensive use of this ability for working with complex data sets.


This latest release can be downloaded from the downloads page or directly with this link:
http://datatables.net/releases/DataTables-1.9.3.zip .

If you find any issues with this release, please open a new thread with a detailed description of the problem, so we can keep track of individual issues.

It takes a lot of time and effort to develop and support DataTables, so if you find it useful, please consider helping further support and development by making a donation towards the project: http://datatables.net/donate .

Enjoy!

Allan

Replies

  • mgmg Posts: 47Questions: 0Answers: 0
    Cool; looks like the mRender function could be extremely useful.

    P.S. I hope the guy who maintains the nuget package for datatables updates the package to 1.9.3.
    http://nuget.org/packages/jquery.datatables
  • gmeridethgmerideth Posts: 7Questions: 0Answers: 0
    Testing datatables 1.9.3 with jQuery 1.8 results in "TypeError: s.charCodeAt is not a function" at line 3841 "var c = s.charCodeAt( s.length-1 );", switched back to 1.7.2, works fine.
  • jblotusjblotus Posts: 6Questions: 0Answers: 0
    @gmerideth i get the same error with jQuery 1.8
  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Can you please link me to a test case with the error. I've not been able to reproduce this yet and thus am unable to debug it.

    Allan
  • gmeridethgmerideth Posts: 7Questions: 0Answers: 0
    Mines unfortunately part of a large internal project so I'd have to try to replicate it on a smaller scale. It uses both jquery, bootstrap and knockoutjs along with a few other input mask and date formatting libraries.
  • gmeridethgmerideth Posts: 7Questions: 0Answers: 0
    OK I think I have something here. I added a console.log(s) to the _fnStringToCss(s) method and I logged a series of numbers, some with "px" on them, most without. Using jQuery 1.8 I suddenly get "[table.table-bordered]" as an object. Somehow jQuery 1.8 is now passing in an object to _fnStringToCss(s). Here's a pic.

    http://imgur.com/U13fx
  • jcreadyjcready Posts: 44Questions: 0Answers: 0
    The fix for the "TypeError: s.charCodeAt is not a function" issue is to upgrade your version of jQuery UI to v1.8.22: http://datatables.net/forums/discussion/11272/uncaught-typeerror-object-object-object-has-no-method-039charcodeat039#Item_16
  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Brilliant! Thanks for the update :-). Great to hear that this has been addressed by them quickly.

    Allan
  • jblotusjblotus Posts: 6Questions: 0Answers: 0
    i can confirm upgrading jquery ui to 1.8.22 fixed it for me
  • superboredomsuperboredom Posts: 7Questions: 0Answers: 0
    edited August 2012
    Has anyone else encountered issues in Firefox 14 with an additional "column" of whitespace between the final table column and the scrollbar? After upgrading to 1.9.3 I am running into this. Works OK in IE 9 and Chrome 21. Here's a pic:

    https://www.dropbox.com/s/xg165464fresvt9/ff_whitespace.png

    I am using JQuery 1.8 and JQuery UI 1.8.23. If I switch back to 1.9.2 the whitespace goes away.

    I am trying to get a "live" version hosted, but the way our apps are configured it's a pain.

    (Also, thanks Allan for your efforts. It's a great product)
  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    edited August 2012
    @superboredom Is this new in 1.9.3? Did it work in 1.9.2? If you could post this in a new thread and with a link to a demo page showing the problem, that would be very helpful.

    *edit* Sorry - I see you say it does work in 1.9.2. If you could post in a new thread, so we can track this individual issue, and a link to a test case, please, that would be great.

    Allan
  • superboredomsuperboredom Posts: 7Questions: 0Answers: 0
    It did work in 1.9.2. Unfortunately the live version of the web app requires a login. So a bit later I will try to create a standalone static version I can post somewhere. There's another issue that I have a question about anyway. =) Thanks for the response.
  • HeoQueHeoQue Posts: 3Questions: 1Answers: 0
    Thanks for the new update !

    The NuGet package for version 1.9.3 seems to be unusual. It does not install all extras as it used to do
  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    @HeoQue: The NuGet package is not maintained as part of this project. Its a third party distribution, so if there are any problems with it, you'll need to ask the package maintainer: http://nuget.org/packages/jquery.datatables .

    Allan
This discussion has been closed.