First row in table not displayed [possible bug?]

First row in table not displayed [possible bug?]

schifferschiffer Posts: 4Questions: 0Answers: 0
edited June 2011 in General
Hello everybody,

I am using DataTables as dynamic table, where you can add or remove rows. Deleting a row is done with calling table.fnDeleteRow(pos[0]); and adding is done with calling table.fnAddData([ /* 1D array as one row */ ]);. Problem occurs when I delete all rows and then I start to add new rows. The 0. row of all added rows doesn't show in table, however the data for 0. row are available in array returned by table.fnGetData();.
This happens only after dynamic deleting of rows, when table is loaded empty (on page load) and then I add row, the row shows properly. (But when I delete it and then try to add it again, it doesn't).
I tried to use table.fnDraw() with true or false parameter after deleting and adding rows, second parameter of fnAddData() or third parameter of fn.DeleteRow() but nothing helped.

There is pictures of how it looks:

When all rows are deleted:
http://i52.tinypic.com/67v7zq.png

When the 0. row is added:
http://i54.tinypic.com/111norp.png

When the 1. row is added: (now 2 rows are in table, but only second is shown)
http://i54.tinypic.com/acvfw7.png

If table has at least one row, adding and deleting of rows is without a problem.

Am I doing something wrong or is this a bug? Can somebody confirm this please?
Thank you for your help.

peter

Replies

  • schifferschiffer Posts: 4Questions: 0Answers: 0
    Ahh, I am sorry for spamming, but somehow I couldn't save new discussion and then it suddenly saved multiple times :-(
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hmm - the forum seems to be doing that a bit at the moment - not sure why that is... I've deleted the other two discussions.

    I've just tried using this example: http://datatables.net/release-datatables/examples/basic_init/zero_config.html - I deleted all the rows using:

    [code]
    $('#example').dataTable().fnDeleteRow(0);
    [/code]

    Until the table was empty and then tried:

    [code]
    $('#example').dataTable().fnAddData([0,1,2,3,4]);
    [/code]

    And it worked as expected. So not sure what is going wrong in your example. If you can give us a link that would be useful!

    Allan
  • schifferschiffer Posts: 4Questions: 0Answers: 0
    Thank you for deleting other discussions.

    I cannot provide a link, as the page where this table is, is available only on our local intranet.

    BUT, I have more information on this problem:
    This problem occurs only when this option is set to -1:
    'iDisplayLength': -1,

    As I need to display all rows at once, I am using it like this. I am not sure if this is correct, or how to setup it when I want all rows visible..

    Can you confirm?
    Anyways, thank you for your quick reply!

    peter
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi Peter,

    I've just tried it with iDisplayLength set to -1 as well, and it seems to work no problem in my example. I'll need to be able to reproduce it before I can figure out what is happening - perhaps you can set up a JS fiddle instance showing the basic problem?

    Allan
  • schifferschiffer Posts: 4Questions: 0Answers: 0
    Hello Allan,

    I understand. So I've created minimal page where this problem occurs. Here is complete index.html:
    http://paste2.org/p/1486817

    The problem occurs with this configuration of DataTables:

    var table = $('#test_table').dataTable({
    'iDisplayLength': -1,
    'bFilter': false,
    'bSort': false
    });

    All three options must be set, otherwise it works OK :-)

    peter
This discussion has been closed.