Table expands after calling a func.

Table expands after calling a func.

handbuchhandbuch Posts: 55Questions: 0Answers: 0
edited September 2010 in General
Please make that the login lasts longer! just lostm y thread.

So my tables expands like that http://img21.imageshack.us/i/tblafter.png/
http://img26.imageshack.us/i/tblnormal.png/

when clicking on the button or the dropwdown. i think i did something wrong with the sDom. http://pastebin.org/1111752

Whats wrong?

notice that the function get Table does work the first time @ document ready

Replies

  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    no idea?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Nope none at all I'm afraid. Can you post a link to an example showing this issue please?

    Allan
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    Hmm, i just thougth maybe i call the gettable twice, but if i did look rigth, i doesnt. Because if i cal lthe getTable() twice at the document,ready i get the same result. And also with bretrieve on true and destroy on false, i dont get it. So it has to do somethign with the iniitilation. :P ^^ Who thougth that^^

    Ehm, yeahm. I will upload it and post it here. I think it is some very stupid basic thing, since im quite new to everything. :)
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    here: http://xotix.bplaced.net/datatables/?action=goodsdrinks got some problem with getting the JSON but it doesnt rly matter since the issue appears without data. just press the button or choos l
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Thanks for the link. I've got to confess I have no idea why it is doing what it is... Could you possibly do me a favour and change your DataTables Javascript include to point at http://datatables.net/dev/jquery.dataTables.bplaced.js so I can try to debug what is going on?

    Thanks,
    Allan
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    i did that. Im rebuilding it right now, its quite chaotic. I remember that i got to these problems when i started to try the stuff with the sDom, but it doesnt look like that causes the problem. Hmm, yeah, i will rebuild it step by step. i Could also send you all files.
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    Hallo, so i caused the error a second time.

    Here my Scripts:
    Index.php : http://pastebin.org/1146592
    drinks.php: http://pastebin.org/1146577

    at drinks, i copied the table html stuff first. then i copied the DrinkGetJSON.php file. then i copied my gettable function and the document ready. so that worked nicely. my table is shown like it should. then i added a button, my deleting scripts and the function to call at drinks.php. i did that, first, without a callback. So i checked somethign, deleted it, refreshed, and it was deleted. so i added getTable() tothe callback, and voila, i got a fat table. ^^

    At the beginning i had it the other way round, like the table went not in the width but in the length. that was because i forgot about 4 colums at thee footer.

    in the past, it worked fine. and i did it like that. hmm. it looks like he doesnt destroy the table.

    try to call getTable twice at the same time, you get that. so i thougth i could empty the otable variable, but that didnt help.

    since im a very newbie, i could easylie done a stupid logical mistake.

    hope that helps you.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I think I've got it - and it's rather convoluted - so not a simple little mistake :-)

    The issue is basically with the table being destroyed and the hidden columns. When DataTables destroys the table, it will set any hidden column back to being visible (since that is how they would be without DataTables). The issue there is that you've got quite a lot of column, and the don't fit into the space available - hence the overflow. Then when the table re-initialises it thinks that the full width is available - so it uses that.

    So... what I've done in the file you linked to (which you are welcome to take a copy of), is to simply set the table back to width 100% when destroy is called. It's not perfect, and it will need some improvement before I commit it to the tree, but it will certainly work in this situation.

    However, is there any need to destroy the table? It doesn't look like you are changing any of the parameters - you could just call fnDraw.

    That's for settings this up to let me debug it!

    Allan
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    ah ok, no, i just once got an error saying me that. Thanks a lot! I will take a look at the fnDraw :)
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    edited September 2010
    So how exactly do i have to use it? i did destroy on false (deleted it) and then i changed the post callback of gettable to otable.fndraw. how do i have to initialise the table?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Only initialise the table once. Then simply call $("#drinks").dataTable().fnDraw();

    Allan
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    edited September 2010
    Thanks, like that doesnt work http://pastebin.org/1148175 no matter if i use the variable or the command. if i want to call it via a button to liek refresh it, nothing happens. outsourced to a function i get the alert after the otable.fndraw. hmm. and my callback works fine. i did initialize the table and added it to otable. http://pastebin.org/1148453

    oh and should my uploaded version work correctly? ^^ since it's connected to your file. and btw i got it installed on a extern suse. i get the json from a php file. im rigth with not using serverside, rigth? since i doesnt have that much of data i can handle it on the client.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It'd be worth downloading that DataTables file and then putting it on your own server, as I'll delete it at some point, and you wouldn't want your app to stop working because of me! Also it saves my bandwidth ;-)

    For the fnDraw - sorry I had thought you were using server-side processing, but from your links above it doesn't look like it - it's just an Ajax source. So when happens, is that you send an Ajax call to the server to update data, and you want the table to then reload and have it show the new data?

    The way to reload data is with this plug-in: http://datatables.net/plug-ins/api#fnReloadAjax . Or alternatively, the destroy that you were doing would work as well (just keep using that version of DataTables I put up - from your own server ;-) ). I'll include a fix for the width issue in 1.7.3.

    Allan
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    edited September 2010
    Hi Allan,

    Thanks a lot for all the Help. But since im new to datatables and js and all that stuff, i need some more help. :) I just Added the AjaxReload Plug In. But it doesnt work in the $.post callback, why? It does work if i use it with a button to manualyl refresh the table. The function has its object when i call it.

    http://pastebin.org/1227646
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Try removing the brackets from the refresh function (ie "refresh" rather than "refresh()" in the $.post.

    Allan
  • handbuchhandbuch Posts: 55Questions: 0Answers: 0
    edited September 2010
    Yeah it works, but i have called the normal reload function via function() :)

    thanks a lot! for all the help and making such a great plugin. =)

    if i would have some spare money i would give you some. someday.
This discussion has been closed.