With the new 1.10 is there the ability to create new columns dynamically? Say I have an ajax source, and I suddenly want to have 3 columns rather then the 2 I have when I initialized datatables, is there an easy way to do that?
I took a look and I saw _fnAddColumn but I was not sure if that is the properly place or what?
No I'm afraid not. There is no public API for adding or removing columns in DataTables 1.10. This is planned (although not 100% certain) for 1.11.
If I wanted to write such a thing because I need it. Do you have any ideas as to where I should start?
Is fnAddColumns not the correct place?
Yes, _fnAddColumn is the place to start there. Have a look at the constructor to see how DataTables uses it, and you'll want to look into the internal aoColumns array as well.
It seems that my problem related to this issue.
I have a lot of different ajax sourced tables, with different numbers of columns and "destroy" option didn't help to render additional columns.
@dubcanada Have you solved this problem? Please could you share your working example?)
I have used a kind of workaround for this issue, i have different views with different columns/tables so what i did is i initialized my datatables with all distinct columns and then hide/show the appropriate ones.
@minohimself thnx for advise!
All features work? what about columns width?
Have you noticed any side effects?
You basically see all columns also those hidden so you have to make sure youre picking the right one other then that not maybe i bit animation would be cool :D, i will now try to link as some the data i show might by type hyperlink
@DataTables any chances we will see dynamic add/remove columns in near future?
Hi - unless this feature is sponsored, it isn't unlikely until 2015 as I'm working on other features at the moment and for the medium term future.
The documentation mentions adding data is "far more efficient" with rows.add, but I was wondering just how inefficient it is to destroy/recreate.
I get that the table might lose various setting such as page, order, filters, etc. but those could be managed separately. So far my tests seem to work fine, and I can post a punker for others if you think it's a good temporary workaround.
To do it fully and properly, including updating the extensions, I would estimate it would be around a weeks work (@8 hours a day, 5 days). That's a rough guess, but if you are interested in this option, I can certainly firm my ideas up and provide a quote offline.
Regarding _fnAddColumn - that was designed for use during initialisation only. It is not designed to add a column at any time and I doubt it could be done after initialisation without breaking other things.
The destroy option is basically the workaround for the moment. Destroy the table - manipulate the columns as you need and then create a new DataTable.
I was wondering just how inefficient it is to destroy/recreate.
I was wondering just how inefficient it is to destroy/recreate.
Everything from the DOM needs to be read in again, so its really dependent on how big the data is, and the data source (if it is Ajax, obviously it will be quicker).
I understand about that quote I'll see if I can get funding approval for something of that magnitude, and thanks.
@DataTables @rikkert Maybe this can be done via Kickstarter or other similar platform?
Many of us would like to see this feature, but unfortunately I can't afford sponsoring full development because of studies, but I would love to give couple of dollars to help.
There are many users out there like me, so if everyone from community would give 1 dollar I think we might get this done 😄
What do You think guys? Do You know page when we could gather money to have this done?
@DataTables , as a option:
Create a community version of DT and provide the commit rights to the specific number of persons in that repository and develop commercial version of DT on the basis of community version.
This will help DT to develop faster, since to one person is very hard to control all commits, check them. and keep pace with competitors.
And, if Allan will go to Kickstarter i'll send him some RUS. Rubles 😄
Thanks for the suggestions - much appreciated! A community edition is certainly possible, although the software doesn't really feel "large" enough to warrant that just yet (my personal feeling about my little piece of software, so I might have the wrong perspective ;-) ). The community edition would also still need to be curated and the feature set kept inline with the pro edition, so it could potentially add extra work. However, accelerating the pace of development for the free software is certainly an attractive option.
BountySource could ease your transition:
+1 that's a crucial feature for my use case as well. I'll try to work around it using destroy :(
Hey there -- just wondering if there's been any movement on this issue? This is a key feature for my use case as well. Thank you!
No sorry. Likely won't be for a little with yet either as I'm working on other aspects of DataTables at the moment.
really looking forward to this feature :)
+1 for dynamic adding/removal of columns.
+1 for adding removing columns
+1 for dynamic adding/removal of columns
This will happen - but there are other features / issues that I'm working on before it. There is no current timeline for when it might be implemented as it is a significant piece of work.
+1 for dynamic adding/removal of columns, we really need it !
+1 for dynamic adding/removal of columns. This would be amazing!
+1 And thank you for your hard work
+for dynamic adding/removal of columns
Why don't you start a small crowdfunding campaign? I suppose everyone on this thread would contribute $20, as this is such an important feature.
How about everyone here posting how much he's prepared to contribute to give Allan an idea?
@temuri416 Great Idea! Count me in. I will need to discus the idea with my colleagues here. But $20 is a minimum.
Heh - thanks all for the feedback - much appreciated. This has to be the feature that has the most votes for inclusion :-).
I am fleshing out my plans for the next major update to DataTables just now and will look at exactly what would be required to include this. I suspect it would be a week or two of work. My problem at the moment is time - I'm spending about 60% of my time on support, so that 1-2 weeks becomes 2-5(ish) and there are other areas I feel I currently need to be working on.
However, I'm not ignoring this!
+1 for this
Hello datatable team,
waiting for this too.
As the others, +1 👍