Tuesday, August 28, 2012
Wednesday, August 22, 2012
Show hide
<script type="text/javascript">
// Text to HTML
// Feedback and questions: Christophe@PathToSharePoint.com
//
var theTDs = document.getElementsByTagName("TD");
var i=0;
var TDContent = " ";
while (i < theTDs.length) {
try {
TDContent = theTDs[i].innerText || theTDs[i].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTDs[i].innerHTML = TDContent;
}
}
catch(err){}
i=i+1;
}
// ExpGroupRenderData overwrites the default SharePoint function
// This part is needed for collapsed groupings
function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
var tbody=document.getElementById("tbod"+groupName+"_");
var wrapDiv=document.createElement("div");
wrapDiv.innerHTML="<TABLE><TBODY id=\"tbod"+ groupName+"_\" isLoaded=\""+isLoaded+ "\">"+htmlToRender+"</TBODY></TABLE>";
var theTBODYTDs = wrapDiv.getElementsByTagName("TD"); var j=0; var TDContent = " ";
while (j < theTBODYTDs.length) {
try {
TDContent = theTBODYTDs[j].innerText || theTBODYTDs[j].textContent;
if ((TDContent.indexOf("<div") == 0) && (TDContent.indexOf("</div>") >= 0)) {
theTBODYTDs[j].innerHTML = TDContent;
}
}
catch(err){}
j=j+1;
}
tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);
}
</script>
// Text to HTML
// Feedback and questions: Christophe@PathToSharePoint.com
//
var theTDs = document.getElementsByTagName("TD");
var i=0;
var TDContent = " ";
while (i < theTDs.length) {
try {
TDContent = theTDs[i].innerText || theTDs[i].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTDs[i].innerHTML = TDContent;
}
}
catch(err){}
i=i+1;
}
// ExpGroupRenderData overwrites the default SharePoint function
// This part is needed for collapsed groupings
function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
var tbody=document.getElementById("tbod"+groupName+"_");
var wrapDiv=document.createElement("div");
wrapDiv.innerHTML="<TABLE><TBODY id=\"tbod"+ groupName+"_\" isLoaded=\""+isLoaded+ "\">"+htmlToRender+"</TBODY></TABLE>";
var theTBODYTDs = wrapDiv.getElementsByTagName("TD"); var j=0; var TDContent = " ";
while (j < theTBODYTDs.length) {
try {
TDContent = theTBODYTDs[j].innerText || theTBODYTDs[j].textContent;
if ((TDContent.indexOf("<div") == 0) && (TDContent.indexOf("</div>") >= 0)) {
theTBODYTDs[j].innerHTML = TDContent;
}
}
catch(err){}
j=j+1;
}
tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);
}
</script>
Sunday, August 19, 2012
configuring a web part
here's the tip for today.... You know how when you add an out-of-the-box web part that requires configuration you get a nice little message in the web part display that you need to configure it, and a link to open up the toolpane? Add a Page Viewer web part to your site and you'll see what I mean.... Well here's how to add one of those links. This is really useful in exception handling for configuration related exceptions too....
In your RenderWebPart override check to see if your part is configured, if not output something like this:
output.Write(@"Web Part not configured: <a target=""_self"" href=""javascript:MSOTlPn_ShowToolPaneWrapper('1','129','g_" + this.StorageKey.ToString.Replace("-"c, "_"c) + @"');"" target=""_self"">click here</a> to configure<br>");
In your RenderWebPart override check to see if your part is configured, if not output something like this:
output.Write(@"Web Part not configured: <a target=""_self"" href=""javascript:MSOTlPn_ShowToolPaneWrapper('1','129','g_" + this.StorageKey.ToString.Replace("-"c, "_"c) + @"');"" target=""_self"">click here</a> to configure<br>");
Sharepoint Allow Customization to users
A lot of people don't realize just how easy it is to create their own “Modify Page” link/button/whatever.... All you really need is something that can have an onClick event.... For example, here's a “Modify Page” button, drop this into a Content Editor web part, strip off the web part frame and you're done...
<input id="btnModifyPage" type="button" class="UserButton" onClick="javascript:MSOWebPartPage_OpenMenu(MSOMenu_SettingsMenu, this);" value="Modify Page" />
So simple, so easy, right? Now because this isn't the actually WebPartPages:SettingsLink web part it will not change text from “Modify Shared Page” and “Modify My Page” depending on the page view you're on.... For most users I don't find that a problem anyway, thus the button text here is “Modify Page” Nice and generic. The functionality is the same however, if a use has access to modify both a personal page and a shared page they can do both from this button..... The javascript command is the same in either case.
<input id="btnModifyPage" type="button" class="UserButton" onClick="javascript:MSOWebPartPage_OpenMenu(MSOMenu_SettingsMenu, this);" value="Modify Page" />
So simple, so easy, right? Now because this isn't the actually WebPartPages:SettingsLink web part it will not change text from “Modify Shared Page” and “Modify My Page” depending on the page view you're on.... For most users I don't find that a problem anyway, thus the button text here is “Modify Page” Nice and generic. The functionality is the same however, if a use has access to modify both a personal page and a shared page they can do both from this button..... The javascript command is the same in either case.
Sharepoint Tweeks and tricks
Is this even possible, some might wonder? Well it is, via querystring options on the command line:
So for example, say you wanted to edit the Shared view of the default page:
default.aspx?mode=edit&PageView=Shared
Say you wanted to Browse web parts and add them to your Personal view:
default.aspx?ToolPaneView=2&PageView=Personal
You can mix and match, and the order of the options do not matter....
Hope this helps
-Andy
| Add Web Parts/Browse | ToolPaneView=2 | |
| Add Web Parts/Search | ToolPaneView=3 | |
| Edit Mode | mode=edit | |
| View Mode | mode=view | |
| Shared Mode | PageView=Shared | |
| Personal Mode | PageView=Personal |
So for example, say you wanted to edit the Shared view of the default page:
default.aspx?mode=edit&PageView=Shared
Say you wanted to Browse web parts and add them to your Personal view:
default.aspx?ToolPaneView=2&PageView=Personal
You can mix and match, and the order of the options do not matter....
Hope this helps
-Andy
Thursday, August 02, 2012
Show ID in Sharepoint Edit Page using javascript
multiple Javascripts from one trigger
<input name="Button1" type="button" value="Submit" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={/thanks-for-submission.aspx}')}" />
Show ID Column from CEWP
<script type="text/javascript">
// Item ID in DispForm.aspx and EditForm.aspx
// Feedback and questions: Christophe@PathToSharePoint.com
//
function DisplayItemID()
{
var regex = new RegExp("[\\?&]"+"ID"+"=([^&#]*)");
var qs = regex.exec(window.location.href);
var TD1 = document.createElement("TD");
TD1.className = "ms-formlabel";
TD1.innerHTML = "<h3 class='ms-standardheader'>Issue ID</h3>";
var TD2 = document.createElement("TD");
TD2.className = "ms-formbody";
TD2.innerHTML = qs[1];
var IdRow = document.createElement("TR");
IdRow.appendChild(TD1);
IdRow.appendChild(TD2);
var ItemBody = GetSelectedElement(document.getElementById("idAttachmentsRow"),"TABLE").getElementsByTagName("TBODY")[0];
ItemBody.insertBefore(IdRow,ItemBody.firstChild);
}
_spBodyOnLoadFunctionNames.push("DisplayItemID");
</script>
<input name="Button1" type="button" value="Submit" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={/thanks-for-submission.aspx}')}" />
Show ID Column from CEWP
<script type="text/javascript">
// Item ID in DispForm.aspx and EditForm.aspx
// Feedback and questions: Christophe@PathToSharePoint.com
//
function DisplayItemID()
{
var regex = new RegExp("[\\?&]"+"ID"+"=([^&#]*)");
var qs = regex.exec(window.location.href);
var TD1 = document.createElement("TD");
TD1.className = "ms-formlabel";
TD1.innerHTML = "<h3 class='ms-standardheader'>Issue ID</h3>";
var TD2 = document.createElement("TD");
TD2.className = "ms-formbody";
TD2.innerHTML = qs[1];
var IdRow = document.createElement("TR");
IdRow.appendChild(TD1);
IdRow.appendChild(TD2);
var ItemBody = GetSelectedElement(document.getElementById("idAttachmentsRow"),"TABLE").getElementsByTagName("TBODY")[0];
ItemBody.insertBefore(IdRow,ItemBody.firstChild);
}
_spBodyOnLoadFunctionNames.push("DisplayItemID");
</script>
Subscribe to:
Posts (Atom)
-
here's the tip for today.... You know how when you add an out-of-the-box web part that requires configuration you get a nice little mes...
-
Is this even possible, some might wonder? Well it is, via querystring options on the command line: Add Web Parts/Browse ToolPaneView=2 ...
-
Dear brothers and sisters, In a world tainted by corruption, we often find ourselves lamenting the state of affairs and expecting the govern...
Followers
No Locks without Key
🌿 Bible Verse 1 Corinthians 10:13 "No temptation has overtaken you except what is common to mankind. And God is faithful; ...
Who Am I?
- Devotion I love to Share
- What is mankind that you are mindful of them, human beings that you care for them? Psalms 8:4 But he made us a little lower than Angels and Crowned with Glory and Honor. How majestic is your name in all the Earth Oh Lord our God!