What is the best way to deal with dynamic columns?
What is the best way to deal with dynamic columns?
Users can select different categories to filter on. Each category appears in it's own jquery ui tab, and the data is displayed using Datatables. Until now, this has all been done in a jsp on the client side. The data is getting too large and I'm going to switch over the using ajax/json.
Currently, when a user makes a change the page is refreshed with all of the different categories (each have a set of columns based on metadata). and all of the data is brought back. The HTML tables are built and when the pages is finished loaded, I initialize Datatables on each table.
For each table, there is a middle set (columns 1-9 and the last column) are fixed. The ones in between are metadata based fields.
Each of these metadata columns have different classes and attributes applied to the TH and TD. I can bring all of this data back, but I'm not sure the best way to use the json being returned to set the different attributes (custom, and sName, sTitle, etc.).
Do I need to ping the database first, build the aoColumns, then pass that into my initialization?
Thanks for any help you can provide.
Eric
Currently, when a user makes a change the page is refreshed with all of the different categories (each have a set of columns based on metadata). and all of the data is brought back. The HTML tables are built and when the pages is finished loaded, I initialize Datatables on each table.
For each table, there is a middle set (columns 1-9 and the last column) are fixed. The ones in between are metadata based fields.
Each of these metadata columns have different classes and attributes applied to the TH and TD. I can bring all of this data back, but I'm not sure the best way to use the json being returned to set the different attributes (custom, and sName, sTitle, etc.).
Do I need to ping the database first, build the aoColumns, then pass that into my initialization?
Thanks for any help you can provide.
Eric
This discussion has been closed.
Replies
If you want to provide information for aoColumns, then yes, - I'm afraid you do need to hit the server with your own Ajax request. You could get the data at the same time and feed it into the table using aaData which would save a second request for the data.
Allan