Dynamically add columns rather than rows with AJAX callback
Dynamically add columns rather than rows with AJAX callback
Hi all,
I have been working with DataTables for a short while and really like the many features and the examples of how to use them. It has made my job a lot easier. Thanks.
For my current project I need to have a table but with the row and column functionality inverted. The table needs to have a fixed number of rows and the number of columns may be dynamic. In this application each column represents a date and as the users scrolls, they see older and older data.
Adding an horizontal scroll bar is easy enough. However, I cannot find a way to dynamically add columns as the user scrolls. There is great support for adding dynamic rows from an AJAX callback but nothing for adding columns dynamically.
Does anyone have a suggestion for dynamically adding columns or are columns required to be fixed?
I have been working with DataTables for a short while and really like the many features and the examples of how to use them. It has made my job a lot easier. Thanks.
For my current project I need to have a table but with the row and column functionality inverted. The table needs to have a fixed number of rows and the number of columns may be dynamic. In this application each column represents a date and as the users scrolls, they see older and older data.
Adding an horizontal scroll bar is easy enough. However, I cannot find a way to dynamically add columns as the user scrolls. There is great support for adding dynamic rows from an AJAX callback but nothing for adding columns dynamically.
Does anyone have a suggestion for dynamically adding columns or are columns required to be fixed?
This discussion has been closed.
Replies
There are two possible work arounds: 1 use column visibility - have a lot of columns and only show the columns you need, or 2. a plug-in could be written to dynamically add and remove columns.
Having said that, the concept of the table having columns x rows rather than the other way around is deeply engrained into DataTables - for example you can do horizontal sorting or filtering, only vertical.
So I'm afraid that DataTables is possibly not suited to that task.
Allan
I want conditionally to add a check box on to each row (either all rows have a check box or not, depending on user's permissions).
Can checkbox markup be included in the json data?
Thanks
I have found that adding the input to the json works:
{ "aaData": [
[ "UP-019209","1/07/2011","Unrated","PPKAEOEX",""]
]}
so the question is, is this the best way to do this, or should I use fnRender() or fnRowCallback() to achieve the desired result?