How do you loop through all columns of a table and tell if it is currently visible or not
How do you loop through all columns of a table and tell if it is currently visible or not
Hi,
I'm looking to loop through all the columns in a table. I want to be able to store the column name and or index so that I can create a table that can be checked. The plan is to allow the user to be able to dynamically toggle the columns on/off. When they like what they see, they click a link and then the database updates with the settings. All of the updating, storage, and looping through for column visibility on next click I believe I can acheive. I just need to loop through all the columns and tell if they are visible or not.
What I currently do is load about 50 columns to the table the hide the ones that the users don't see. We use the same table for about 50 processes. So the columns needed are different. In what I've learned, once you load them all then you need to click on the toggle links to hide those. I currently use links that the user could click on, but I click on those for the user with jquery. So the concept is to just loop through all the columns, if it is visible, who cares... but if they are hidden then I need to grab the data value and the index to store and retrieve in the database.
I hope this is making sense.
Answers
Hi All,
What an amazing tool. I figured it out and want to share if you need it.
In case you are interested, this is how I would show after pulling the string hiddencols from database:
Very nice - thanks for sharing your solution with us!
Allan
So after 2 days of working out the bugs, I build a bunch of functions that you could replace the ajax calls with your site.
This is a complete solution how I implement this in sharepoint 2010. We display about 70 columns of data that are needded for different users at different times. I use normal links within the page that call the data to display in the the table which I call quick filters. When the user clicks on the ID, I store the user's name, the page, the id clicked, then all the visible columns. When the user clicks on the quick filter again, then the settings are retrieved, all columns are displayed, and if there is data for that page and quick filter, then the columns that are on record are hidden. There is also a process to remove that data so that the hard coded standard columns that are required for those fields are avaialble. This might be when you have a set of fields you want the user to see, they set the ones they want to see, then they realize they need to revert back to the standard listing.
Please note I did remove specific list setting references here so you will need to look those up by googling to see the _vti_bin/ListData.svc/ for your site.