DataTables 1.8 beta 3 now available

DataTables 1.8 beta 3 now available

allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
edited May 2011 in General
Hello all,

Continuing the DataTables 1.8 beta series, I'm very pleased to announce the availability of 1.8 beta 3.

Beta 3 Package download: http://datatables.net/releases/DataTables-1.8.0.beta.3.zip

What's new in 1.8: http://datatables.net/new/1.8
Upgrade notes: http://datatables.net/upgrade/1.8
Original 1.8 announcement: http://datatables.net/forums/comments.php?DiscussionID=4852

This latest beta of DataTables 1.8 focuses on stabilising the new features that are being introduced as part of the 1.8 series, and includes a number of bug fixes particularly around the areas of deferred rendering and TH elements in the table body. Also of note is that I've rewritten the algorithm used for calculating column widths when x-scrolling is enabled, and other more general improvements in column width calculation when scrolling is not enabled.

In addition to the bug fixes, there are a couple of low impact new features which are introduced in this beta, including:

- The ability to have default content for a column (an edit image is an option for example), which is used when mDataProp is null
- A new callback function called 'fnPreDrawCallback' which can be used to pre-process or cancel a draw
- A new language option called 'sLoadingRecords' which is used when Ajax sourced data is being loaded.

I'd encourage everyone to try out the beta and let me know if you run into any upgrade problems, or any other issues with the latest beta so I can start thinking about wrapping the 1.8 beta series up and releasing 1.8.0 :-)

Enjoy!
Allan

Replies

  • sd_zuosd_zuo Posts: 78Questions: 1Answers: 0
    Hi Allan,

    What's the "Default content for a column"?
    Does or can this feature address the null value issue too?

    To eliminate the null values is pretty nasty.
    I am afraid it will burden the server if the JSON null pre-process is performed on the server side.
    And if it is processed on the client side, there're so many places need to fix :(

    It is strange that no other people meet with and report this issue while we are discussing this.
    I just wonder whether others can handle this neatly.
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    The default content for a column (sDefaultContent) is used whenever mDataProp for a column is empty. To come extent it can be used to transform null values into something else - but only when the data is read through the data get function _fnGetCellData. This is not the case when using fnRender or fnGetData - this methods simply return the value that you fed into DataTables. So if you feed in null, then in fnRender you get null. As I noted in the other thread where we discussed this, I do not currently plan to alter this behaviour in DataTable 1.8 since I believe it was wrong in the first place in 1.7, and has now been altered to be the correct behaviour. In 2.0 and beyond there will be customisation options which allow for this, but that is a good little way away.

    If this change does break backwards compatibility for a large number of applications, then I will look at altering DataTables to provide null transformation as an option - which is why I would encourage as many people as possible to test 1.8 and see how it performs in their application :-) particularly as I hope to move towards a release of 1.8.0 reasonably soon.

    Allan
  • fhafha Posts: 4Questions: 0Answers: 0
    Hello Allan,
    I wanted to give you a heads up and thank you for the update.

    I haven't tried this version yet, but, while trying to implement "ColVis" functionality, found a problem in that plugin. It's still version 1.0.4 in this beta (same in version 1.7.6), so, this problem will occure in stable too if used with current stable version of jQuery >1.6 instead of the bundled version, 1.5.1.

    Since the introduction of jQuery 1.6 (which I started to use last week) there has been a major change about how .attr() method works on checkboxes. So, since then, the buttons to enable and disable columns would just not work. ColVis plugin would need a change in method _fnDomColumnButton, so that lines 454 and 457 check/set the checked attributes via new .prop() method rather than .attr(). This change will break compatibility with older versions of jQuery though :-/

    I'm posting this in the beta thread because I don't know your current release cycle, especially regarding the bundle of DT with newer versions of jQuery.

    Regards,
    fha

    PS: Please also refer to http://blog.jquery.com/2011/05/03/jquery-16-released/ if that particular change is unknown to you.
  • sd_zuosd_zuo Posts: 78Questions: 1Answers: 0
    Hello Allan,

    Thanks for the reply.
    Since this null value issue does impact my applications a lot, fixing them will take quite some considerable time, and currently tasks overflows my scheduler ^__^, thus I will sit back and wait for the final release.
    If I am the 'single case', I will consider fixing this manually here after release is born.
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    @sd_zuo: Yup - understood. The change itself in DataTables is trivial if you wanted to create a fork and put it in. Just add a null check in here and replace with an empty string: https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L6580 . That will happen one cell at a time though, so if you reference other cells in fnRender they might or might not have been 'corrected'. As I say, I think it would be best to do it on the server if needed. Or to just keep using 1.7.x :-)

    @fha: Thanks for flagging this up. I was aware that the jQuery folks had changed the $().prop and $().attr methods in 1.6 - and they've not reverted them in 1.6.1: http://ejohn.org/blog/jquery-16-and-attr/ . I've not really tested 1.6.x yet, so I'd be interested to know how 1.6.1 goes for you.

    I'm a bit surprised that 1.6.0 did actually break ColVis since the only place that it uses it is for the 'checked' property of the checkboxes. This is probably part of the problem the jQuery team face since checked is valid as both an attribute and a property...

    Allan
  • fhafha Posts: 4Questions: 0Answers: 0
    Hello allan,

    in general, DT works just fine with jQuery 1.6.1. I came across one problem with Ajax which interferes with an old "loading"-plugin I used (I use mostly serverside processing of tables), but didn't have time for evalutation of the real cause of that problem yet. I'll let you know if I find out that DT is the reason :-)

    Regards,
    fha
  • tacman1123tacman1123 Posts: 198Questions: 46Answers: 1
    Feature request: "Refresh" icon.

    I'm pleased to see that datatables is offering more / better server-side support. Since often the data changes outside of the datatables UI, I find myself refreshing the entire page to see the new data. Any chance you could seamlessly integrate a "Refresh" button (e.g. http://www.iconspedia.com/icon/table-refresh-icon-22001.html). It feels like one belongs there, and I'd certainly use it a lot in testing but also in production. (Actually, in production I might tie it to a timer and auto-refresh the data periodically, but it'd be nice to have a manual option integrated and available).

    Thx,

    Tac
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    @fha: If you use the Validation plug-in for jQuery at all - then that might be the first place to look. Good to hear that DataTables does the job with 1.6.1 though. I'll be running it through my unit tests soon.

    @Tac: A refresh button is already quite possible using either the fnDraw API function (when using server-side processing) or http://datatables.net/plug-ins/api#fnReloadAjax when using a Ajax sourced data. All you need to do is create a tag and attach an event handler to it to call one of these API methods. This allows a lot more flexibility than having it in the core, and also keeps the core down to a sensible size.

    Regards,
    Allan
  • tacman1123tacman1123 Posts: 198Questions: 46Answers: 1
    Yes, that's possible, but my button doesn't have the right "look". We're porting from jqgrid, which has the refresh integrated as a tiny button on the bottom border. I guess if I could figure out how to add an icon or button to the "Displaying 1-10 of 300" text, or the records-per-page dropdown it would go okay there. It needs to be within the table div, or it looks orphaned.

    Anyway, I see now that the real issue isn't the couple of lines of code to add the refresh button to the UI, but rather that the fnReloadAjax is a plug-in and not part of the core, so it wouldn't make sense to add the UI element to the core.

    Thx.
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    I'd suggest using TableTools and setting up a button to call the fnReloadAjax plug-in when it is clicked on: http://datatables.net/extras/tabletools/ . TableTools was developed for exactly this kind of flexibility to add buttons seamlessly to a table, while being very configurable.

    Allan
  • GleebleGleeble Posts: 14Questions: 0Answers: 0
    Allan,

    Just upgraded to the B3 and noticed a new problem, which is one of the "fixes" judging by the release notes. Basically, all of my tables now display the "Loading..." text even if there is no data. I assume this is due to my using json objects but I don't send a server request for these, any objects I'm going to have are loaded prior to the table being generated so if the empty array is provided and empty it should display the no data message.

    -Adam
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    Agreed - if aaData is empty, DataTables should show the empty message. Could you possibly give me a link to your page please, so I can see it in action and what might be going wrong?

    Thanks,
    Allan
  • ysidhuysidhu Posts: 1Questions: 0Answers: 0
    Hi, first I want to say that DataTables rocks - thanks for the excellent work and documentation!

    I just downloaded 1.8 beta 3 and I have everything working except I'm having some issues with the TableTools plugin. I noticed that this plugin is not bundled in the /extras directory in this release. Is that by design?

    I went ahead and downloaded the latest plugin and still experiencing issues... not sure if it's been completely tested with 1.8 beta 3?
  • sd_zuosd_zuo Posts: 78Questions: 1Answers: 0
    Hello Allan,

    I designed to rollback to 1.7.6 for some moment for the null value issue.
    I will check back later.
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    @ysidhu: no that wasn't intentional at all! It looks like there is a small packaging error with my build scripts at the moment... You can download the TableTools package from the downloads page, or as part of the 1.7.6 release. I'll make sure this the update is included in beta 4.

    Regards,
    Allan
  • rjonesrjones Posts: 6Questions: 0Answers: 0
    I may be able to assist a little more with the permanent "loading" message when there is no data matches available. It does not matter whether it is an Ajax scenario or not...

    I can recreate that same situation with a normal self contained (and well formed) table, with the stock beta package (no additional plug-ins or changes). BUT ONLY when I provide a sSearch parameter on initialization that DOES NOT MATCH anything in the database.

    I'm sure that there are other situations, but I thought that this one might help track it down.

    Just in case it's a very strange combination of settings, here's my particular initialization file.

    [code]
    $(document).ready(function() {
    $('#mydatatable').dataTable( {
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": true,
    "bSort": true,
    "bInfo": false,
    "bAutoWidth": false,
    "aoColumns": [
    { "bSearchable": false },
    { "bSearchable": false },
    null,
    { "bSearchable": false },
    { "bSearchable": false },
    { "bSearchable": false },
    ],
    "oSearch": { "sSearch": "fakeTextThatDOES_NOT_EXIST_Anywhere_IMPORTANT", "bRegex": false, "bSmart": true },
    } );
    } );
    [/code]

    Note this is trivial and I wouldn't even mention it except that it may help track down Gleeble's permanent "loading" message on an empty data set...?
  • GleebleGleeble Posts: 14Questions: 0Answers: 0
    Thanks for adding in your own situation rjones hopefully it helps out some as well. Allan below you'll find the page source that is generated in the JSP. This is just one example, but I have noticed it in other tables of mine as well.

    [code]





    Description





    Date







    Loading...



    //<![CDATA[
    function taskPopUp(actionUrl, actionId) {
    $('#taskDialog').load('/root' + actionUrl).dialog('open');
    }


    $(document).ready(function() {
    var dataRows = [];
    var isLongData = dataRows.length > 10;
    $('#taskTable').dataTable( {
    "aaData" : dataRows,
    "bInfo" : isLongData,
    "bLengthChange": isLongData,
    "bPaginate": isLongData,
    "aoColumns": [{"mDataProp": "description"},
    {"mDataProp": "dateAdded", "stype" : "date",
    "fnRender" : function(obj) {
    return formatDate(obj.aData.dateAdded);
    }}
    ],
    "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
    var td = $("td", nRow).first();
    var txt = td.text();
    td.text('');
    if(aData.modal) {
    $('',{
    text: txt,
    id: "task_" + aData.taskActionTargetId,
    href: '#',
    click: function() {
    taskPopUp(aData.taskActionUrl, aData.taskActionTargetId);
    }
    }).appendTo(td);
    } else {
    $('',{
    text: txt,
    id: "task_" + aData.taskActionTargetId,
    href: "/root" + aData.taskActionUrl
    }).appendTo(td);
    }
    return nRow;
    }
    } );

    $.subscribe('dialogClosed', function(event,data) {

    $("#taskDialog").html('');
    });
    })

    //]]>

    [/code]
  • pgalganopgalgano Posts: 6Questions: 0Answers: 0
    edited May 2011
    From reading the documentation and looking through the code it appears that I should be able to set sAjaxSource to empty string which implies that I will set aaData manually myself. The problem I am running into with beta 3 is that when I set this to empty string the following line at 2377 will cause it to try to do a getJSON call using the empty string for the url since it is only checking against null.
    [code]/* if there is an ajax source load the data */
    2377 if ( oSettings.sAjaxSource !== null && !oSettings.oFeatures.bServerSide ) [/code]

    The main issue I am having and was trying to work around is that when I load my datatable currently I will get the loading string in the datatable box, where the preference would be to have the empty message. There is logic in the init block that says if the sAjaxSource is set to "" then use the empty message, but I blow up with an alert when setting that option do to the line above. bServerSide is set to false.

    I do have a workaround in that I can not set the sAjaxSource property at all and can call datatable.fnClearTable(); right after initializing but wanted to post as the above seemed like a defect.
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    sAjaxSource being set to anything other than null suggests to DataTables that there is an Ajax source and it should get the data using that method. An empty string is actually valid, and means that it should pull in data using the current page's url - which is almost certainly not what you would want (a quirk of the RFC).

    In DataTables 1.8 there is a new language string called "sLoadingRecords" which you can set to be an empty string if you don't want any message when the table is loading.

    Allan
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    @rjones and Gleeble: Thanks very much for flagging this up and the debugging! That was very useful :-). I had an incorrect check against the Ajax source property which would result in that error.

    @pgalgano: This might have effects your results as well!

    I've just committed a fix and it is available as the "nightly" on the downloads page ( http://datatables.net/download ).

    Regards,
    Allan
  • daniel.abeldaniel.abel Posts: 1Questions: 0Answers: 0
    edited May 2011
    The "Complex headers" section of the release notes (http://www.datatables.net/new/1.8) says that "This is tightly integrated to the core and thus allows the ColVis extra and others to 'just work' with complex headers. " ColVis works great, but I think I am having issues with ColReorder. (using DataTables 1.8.0beta3, in Firefox 3.6.17):
    I applied the following diff to the "complex header" example:
    [code]
    11a12,14
    >
    >
    >
    13a18,19
    >
    >
    16a23
    > "sDom": 'RC<"clear">lfrtip',
    [/code]

    Reordering the columns sort-of works, but appears to be buggy. I can grab and drag the "Engine version" column header, and when dragging it outside of the "Details" colspan, the drop-target marking blue line appears even though I can't drop there. (Nothing happens after the drop); Similarly, the "Browser" column-header can be dropped inside the "Details" colspan, between those two columns, but it ends up on the other side of the "Details" double-column (where my beef is not where it ends up, but the fact that the drop-target appears where it cannot be dropped).

    Dragging the "Engine version" header appears to actually drag the "Browser" header (the text of the dragged item is "Browser", and dropping it moves the browser column, not "Details" or "Engine version").

    Is support for ColReorder with colspan/rowspan (complex headers) planned for 1.8? Are the issues described above known bugs?

    Thanks in advance,
    Daniel Abel
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    Hi Daniel,

    I'm not too surprised that ColReorder with complex headers doesn't work quite as expected I'm sorry to say. There isn't any code in ColReorder which would allow, for example, a cell with a rowspan of 1 to suddenly become a column with a rowspan of 2. This is something for the ColReorder plugin to address in a future version I think, so not something that will be in or hold back the DataTables 1.8 release.

    Regards,
    Allan
  • GleebleGleeble Posts: 14Questions: 0Answers: 0
    Thanks Allan, I will check it out when I get a chance. Always glad to help.
This discussion has been closed.