Comments on: SharePoint: Toggle column visibility in list view http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/ No GeekSpeak on SharePoint 2007 WSS and MOSS Sat, 25 Dec 2010 14:38:56 -0500 http://wordpress.org/?v=2.8.6 hourly 1 By: William http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-120679 William Fri, 24 Dec 2010 06:27:38 +0000 http://www.endusersharepoint.com/?p=7420#comment-120679 Dear all, Can this script work in SharePoint 2010 Dear all,

Can this script work in SharePoint 2010

]]>
By: Scott http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-88169 Scott Mon, 26 Jul 2010 14:29:38 +0000 http://www.endusersharepoint.com/?p=7420#comment-88169 I found your code while trying to search for a solution for something that I am trying to do in SharePoint. I was wondering if your code could be used for my solution with some minor tweaks or if I should be looking for something totally different. Basically, we want to create a page that shows a list of courses, and then when you click on a course, the description shows up. Initially, I was thinking to create a list of the courses, and then tie that into another web part that just had the descriptions in there. When you click on the course, then it would display the description. Both web parts would be on the same page. I then saw your code here, and thought that maybe it doesn't have to be that complicated, that we could show the list of course with the checkboxes, and then when clicked, it would show the description. That would require changes to hide/unhide rows instead of columns. Is that an easy modification? Am I off base on this? I am a novice developer, so I understand some not all about how the code is written. I know that it looks for the first table and grabs the display names of the columns. For the rows, I see that the unique identification for the rows is the ID name, but not sure how to incorporate that. Any help you can give is greatly appreciated! I found your code while trying to search for a solution for something that I am trying to do in SharePoint. I was wondering if your code could be used for my solution with some minor tweaks or if I should be looking for something totally different. Basically, we want to create a page that shows a list of courses, and then when you click on a course, the description shows up. Initially, I was thinking to create a list of the courses, and then tie that into another web part that just had the descriptions in there. When you click on the course, then it would display the description. Both web parts would be on the same page. I then saw your code here, and thought that maybe it doesn’t have to be that complicated, that we could show the list of course with the checkboxes, and then when clicked, it would show the description. That would require changes to hide/unhide rows instead of columns. Is that an easy modification? Am I off base on this?
I am a novice developer, so I understand some not all about how the code is written. I know that it looks for the first table and grabs the display names of the columns. For the rows, I see that the unique identification for the rows is the ID name, but not sure how to incorporate that.

Any help you can give is greatly appreciated!

]]>
By: Marta http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-74983 Marta Wed, 16 Jun 2010 10:31:06 +0000 http://www.endusersharepoint.com/?p=7420#comment-74983 sorry don't know why it did not get pasted all the last time // To "pre uncheck" checkboxes, add names to this array var arrOfPreHiddenColumns = ['Customer name',Customer number','Sales Manager','Country','City',Core Segment','Subsegment','Technology','Specific Techn','End Use','Est Close Yr','Est Close Qtr','Opp Status','Sales Status','Est Current Year €K','Est Annual €K','Est Annual Volume','Sales Comment','Competitor','Incumbent','WonLoss','Won/Loss Reason','LWR Number','EMEA Region','Carry over','Created By','Modified By']; // Pull columns to "pre uncheck" from the query string parameter "ColumnsToHide" var qStrPAram = getQueryParameters(); var colFromQueryString = qStrPAram.ColumnsToHide; if(colFromQueryString!=undefined){ arrOfPreHiddenColumns = arrOfPreHiddenColumns.concat(colFromQueryString.split(',')); } init_Checkboxes(arrOfPreHiddenColumns); sorry don’t know why it did not get pasted all the last time

// To “pre uncheck” checkboxes, add names to this array
var arrOfPreHiddenColumns = ['Customer name',Customer number','Sales Manager','Country','City',Core Segment','Subsegment','Technology','Specific Techn','End Use','Est Close Yr','Est Close Qtr','Opp Status','Sales Status','Est Current Year €K','Est Annual €K','Est Annual Volume','Sales Comment','Competitor','Incumbent','WonLoss','Won/Loss Reason','LWR Number','EMEA Region','Carry over','Created By','Modified By'];

// Pull columns to “pre uncheck” from the query string parameter “ColumnsToHide”
var qStrPAram = getQueryParameters();
var colFromQueryString = qStrPAram.ColumnsToHide;
if(colFromQueryString!=undefined){
arrOfPreHiddenColumns = arrOfPreHiddenColumns.concat(colFromQueryString.split(’,'));
}
init_Checkboxes(arrOfPreHiddenColumns);

]]>
By: Marta http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-74957 Marta Wed, 16 Jun 2010 09:01:16 +0000 http://www.endusersharepoint.com/?p=7420#comment-74957 Hi Bill, a question, is there a limit to the number fo columns? I cannot make it work in my list view, there is no error message. All the links and reference to .js seem to be correct but yet the checkboxes don't appear. My CEWP script below: [sourcecode lang="javascript"] // To "pre uncheck" checkboxes, add names to this array var arrOfPreHiddenColumns = ['Customer name',Customer number','Sales Manager','Country','City',Core Segment','Subsegment','Technology','Specific Techn','End Use','Est Close Yr','Est Close Qtr','Opp Status','Sales Status','Est Current Year €K','Est Annual €K','Est Annual Volume','Sales Comment','Competitor','Incumbent','WonLoss','Won/Loss Reason','LWR Number','EMEA Region','Carry over','Created By','Modified By']; // Pull columns to "pre uncheck" from the query string parameter "ColumnsToHide" var qStrPAram = getQueryParameters(); var colFromQueryString = qStrPAram.ColumnsToHide; if(colFromQueryString!=undefined){ arrOfPreHiddenColumns = arrOfPreHiddenColumns.concat(colFromQueryString.split(',')); } init_Checkboxes(arrOfPreHiddenColumns); [/sourcecode] Hi Bill,
a question, is there a limit to the number fo columns?
I cannot make it work in my list view, there is no error message. All the links and reference to .js seem to be correct but yet the checkboxes don’t appear.

My CEWP script below:

// To "pre uncheck" checkboxes, add names to this array
	var arrOfPreHiddenColumns = ['Customer name',Customer number','Sales Manager','Country','City',Core Segment','Subsegment','Technology','Specific Techn','End Use','Est Close Yr','Est Close Qtr','Opp Status','Sales Status','Est Current Year €K','Est Annual €K','Est Annual Volume','Sales Comment','Competitor','Incumbent','WonLoss','Won/Loss Reason','LWR Number','EMEA Region','Carry over','Created By','Modified By'];

// Pull columns to "pre uncheck" from the query string parameter "ColumnsToHide"
	var qStrPAram = getQueryParameters();
	var colFromQueryString = qStrPAram.ColumnsToHide;
	if(colFromQueryString!=undefined){
		arrOfPreHiddenColumns = arrOfPreHiddenColumns.concat(colFromQueryString.split(','));
	}
	init_Checkboxes(arrOfPreHiddenColumns);
]]>
By: Ben http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-68981 Ben Tue, 18 May 2010 22:27:26 +0000 http://www.endusersharepoint.com/?p=7420#comment-68981 This is very tidy code, pretty much covered everything you can think of, I especially like the including the refresh of hidden details on group expansions. However I had a slight problem when dropping multiple list views on a page. I found that whilst the content of the columns were hidden in every list view the column header was only hidden on the first list view. I got round this by writing my own code to recursively look through and hide each of the column headers. The issue was with function hidecolumn it hides the column header and then all content. But whilst it finds each content cell (and by that rule hides every instance in every web part) it only does the first column header. I have only started hacking with Jquery and javascript over the past week or so, so it's not very elegant but I got round it by doing this.... (I had to hard code the column header name) [sourcecode lang="javascript"] $(".ms-viewheadertr >*[class^='ms-v']").each(function(){ var thToToggle = $(this).find("[name*='Profiles']"); thToToggle.hide(); }); [/sourcecode] This is very tidy code, pretty much covered everything you can think of, I especially like the including the refresh of hidden details on group expansions.

However I had a slight problem when dropping multiple list views on a page. I found that whilst the content of the columns were hidden in every list view the column header was only hidden on the first list view.

I got round this by writing my own code to recursively look through and hide each of the column headers.

The issue was with function hidecolumn it hides the column header and then all content. But whilst it finds each content cell (and by that rule hides every instance in every web part) it only does the first column header.

I have only started hacking with Jquery and javascript over the past week or so, so it’s not very elegant but I got round it by doing this…. (I had to hard code the column header name)

$(".ms-viewheadertr >*[class^='ms-v']").each(function(){
    var thToToggle = $(this).find("[name*='Profiles']");
   thToToggle.hide();

    });
]]>
By: Mike http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-68879 Mike Tue, 18 May 2010 15:00:30 +0000 http://www.endusersharepoint.com/?p=7420#comment-68879 This is really impressive. I love it! My users will drool all over this feature. This is really impressive. I love it! My users will drool all over this feature.

]]>
By: EndUserSharePoint http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-68857 EndUserSharePoint Tue, 18 May 2010 13:26:21 +0000 http://www.endusersharepoint.com/?p=7420#comment-68857 David - Mouse over the code. A context menu pops up in the right hand corner. Click the "Code" icon and it will open in plan text view for copying. -- Mark David – Mouse over the code. A context menu pops up in the right hand corner. Click the “Code” icon and it will open in plan text view for copying. — Mark

]]>
By: Bill Garvey http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-68855 Bill Garvey Tue, 18 May 2010 13:24:20 +0000 http://www.endusersharepoint.com/?p=7420#comment-68855 When you refer to script, are you only referring to the jQuery and ToggleColumnVisibility scripts, or are you placing the content of the CEWP in a text file, and calling that using "Content Link" I have found that if you try and call a CEWP script that is not on the site (i.e. using the "Content Link" in the CEWP) the location where the script resides MUST have anonymous access turned on: http://office.microsoft.com/en-us/sharepointserver/HA100240461033.aspx "If the Content Link property links to a file that is located outside the site and the site does not have anonymous user access enabled, you cannot access the file. For assistance, contact your site administrator." I believe even if you are in the same collection, you must have it turned on. So if you are calling, using "Content Link", a script that in on the top level, you may need to turn on anonymous access to that folder. Sorry if this is not your situation. I am able to load the CEWP content in via source editor, and point to the jQuery and Toggle scripts using fully qualified URLs of an offsite "resource center" with no problems. When you refer to script, are you only referring to the jQuery and ToggleColumnVisibility scripts, or are you placing the content of the CEWP in a text file, and calling that using “Content Link”

I have found that if you try and call a CEWP script that is not on the site (i.e. using the “Content Link” in the CEWP) the location where the script resides MUST have anonymous access turned on:

http://office.microsoft.com/en-us/sharepointserver/HA100240461033.aspx

“If the Content Link property links to a file that is located outside the site and the site does not have anonymous user access enabled, you cannot access the file. For assistance, contact your site administrator.”

I believe even if you are in the same collection, you must have it turned on. So if you are calling, using “Content Link”, a script that in on the top level, you may need to turn on anonymous access to that folder.

Sorry if this is not your situation. I am able to load the CEWP content in via source editor, and point to the jQuery and Toggle scripts using fully qualified URLs of an offsite “resource center” with no problems.

]]>
By: David Hamilton http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-68852 David Hamilton Tue, 18 May 2010 13:20:12 +0000 http://www.endusersharepoint.com/?p=7420#comment-68852 Never mind. Copying the code with line numbers screws it up. Better to view source and copy that, as you suggested. Never mind. Copying the code with line numbers screws it up. Better to view source and copy that, as you suggested.

]]>
By: David Hamilton http://www.endusersharepoint.com/2010/04/23/sharepoint-toggle-column-visibility-in-list-view/comment-page-1/#comment-68845 David Hamilton Tue, 18 May 2010 12:56:28 +0000 http://www.endusersharepoint.com/?p=7420#comment-68845 Not showing anything at all. The Script Library is in a top level site, and the CEWP code points to that location. I have tried this with absolute and relative references, makes no difference. Creates a special page for the list, placed the CEWP below or above the list. Makes no difference. Made sure that Full Toolbar was on (per your example). Nothing shows above the Toolbar. Any thoughts about this? Potential mistakes? Not showing anything at all.

The Script Library is in a top level site, and the CEWP code points to that location. I have tried this with absolute and relative references, makes no difference.

Creates a special page for the list, placed the CEWP below or above the list. Makes no difference.

Made sure that Full Toolbar was on (per your example).

Nothing shows above the Toolbar.

Any thoughts about this? Potential mistakes?

]]>