fnOpen on empty table?

fnOpen on empty table?

carteriiicarteriii Posts: 25Questions: 1Answers: 0
edited October 2010 in General
I have been using fnOpen to allow users to update or delete rows from a table with server side processing. That has been great.

Now I would like to use the same approach to adding new data. I'd like to basically open a row, allow the user to insert the data, press "Save", and then redraw the table. This works fine when I can call fnOpen on an existing row, but I am unable to make this work when the table is initially empty.

I tried calling fnOpen using the tr element within the thead, but it appears that DataTables only allows fnOpen to work on tr elements within the tbody. I've tried first calling fnAddData, but that just doesn't seem to work when server processing is enabled. I found this discussion, http://datatables.net/forums/comments.php?DiscussionID=2674, which mentions that the second parameter to fnAddData needs to be false, but I am still unable to have a row added using that.

So in summary, is it possible to get fnOpen() to work when I do not already have a row in the table? A workaround might be to have the server return a fake row whenever there isn't any real data, but I'd prefer to get this to work cleanly if possible.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The basic answer is, no this is not possible. fnOpen was designed to work on a row in the table, and since you have no rows, there is nothing to "open". It sounds like what you might want to do is not open a row (since that is then attached to the "parent", but rather just append a newly created TR/TD to the table, which will then be automatically removed when the table redraws (i.e. the save).

    Allan
This discussion has been closed.