Dynamically Adding a Column at the End

Dynamically Adding a Column at the End

soberspsobersp Posts: 28Questions: 0Answers: 0
edited October 2009 in General
Hi Grp

Can anyone tell me or point me to any specific topic in forum which describes how to add a Column Dynamically

I am adding a Column at the Begining of the table as described in,

http://datatables.net/examples/server_side/row_details.html

-in the CallBack but am not able to figure out how to add a Column at the End....

Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi sobersp,

    DataTables doesn't really allow columns to be added dynamically. The example you posted shows how to add a child row, is that what you were meaning? It is possible to hack around the lack of dynamic column support in DataTables, but it's not really recommended practice... :-)

    Regards,
    Allan
  • soberspsobersp Posts: 28Questions: 0Answers: 0
    1st'ly Thanks Allan for your reply...

    The Problem I was facing was in IE-6 to add a Column at the End, Similar to what is done in the above example
    In Above Example you are adding the 1st Column (Action Col), Similarly I need to add one more at the End....
    I got around it, but my problem is, even after unbinding the 'Click' event, I face Browser Freeze problem
    After some time the browser freezes....Note : I refresh the Page every 5 secs using fnRedraw...
    Sorry if this is a jQuery/JavaScript kinda question.... but thought if you can add some light to the issue, ...!!

    Alternatively, what do you suggest when you are doing Server Side Processing to Add a Action Column, Best Practice for DataTables... ??

    Thanks VeryMuch
    Sobers
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Sobers,

    One thing that is very important when dealing with events and DataTables, particularly when adding and removing rows (this is what happens effectively with server-side processing or reloading an Ajax source), is that the events which are bound to the elements in the table must be unbound, otherwise you will run into a memory leak situation. Have a look at this post (and the thread in general) which might help explain this a little more: http://datatables.net/forums/comments.php?DiscussionID=643#Item_6

    This is what I think you will be running into if it works to start with, but freezes later on.

    Regards,
    Allan
  • soberspsobersp Posts: 28Questions: 0Answers: 0
    Hey Allan

    Thanks for the Quick Reply. I did try the link and try to Unbind the Click Event. I also tried to add a Alert Box in the loop to check if it actually gets called, and it does, for the number of rows in the table... Maybe I am doing something wrong. I will post the code soon in reply to this thread and you can check if any thing seems goofy...

    Thanks a loot for your help....Need to buy you a beer

    Sobers
This discussion has been closed.