I have now disabled comments on this blog as I am starting to get an unmanagable number of spam comments. If you wish to contact me then please send me a personal message through sharepointexperts.com – my username is lishmanm.
I have now disabled comments on this blog as I am starting to get an unmanagable number of spam comments. If you wish to contact me then please send me a personal message through sharepointexperts.com – my username is lishmanm.
(Reposted due to undeletable spam comments)
So I have created a web part that is a calulation based on various fields in various lists on the site. It displays a table full of data and some text stuff. The client wanted to be able to print just what could be seen in the web part and not all the nice looking stuff around it.
It took me a while to figure this out and it was with the help of this link:
http://personalweb.about.com/od/copypastejavascripts/a/404_3scripts_3.htm
So I was lucky in the fact that my output was just a stream of html so I put div tags around the stuff I wanted to print like this – <div id='printPart'> print this bit</div>
and then just added the code to the head of the page (must do this in FrontPage) where the webpart was like this:
<script>
function printSpecial()
{
var html = '<HTML>
<HEAD>
';
if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}
html += '
</HEAD>
<BODY>
';
var printReadyElem = document.getElementById("printPart");
if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printPart div");
return;
}
html += '
</BODY>
</HTML>';
var printWin = window.open("","printSpecial");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
printWin.print();
}
</script>
It all needs a bit of fine tuning but in essence it works a treat!
Ihave been working on populating a field with items from another list depending on what I pick in the previous field and have got a bit further on. I now have a list where one of the lookup fields fills depending on what you have picked in the previous field.
Here is the code that I am using: note that I use a button to call the script as I put this in the editform and if I leave the code on the onblur event it will remove any existing data that I have in the filtered lookup that may already be correct.
<script>
function RepopulateList(fieldValue)
{
// — retrieve the list for the elements
var siteName = "http://www.xyz.com/site";
//the next field is the name of the field that you want to appear as filtered
var controlName="urn:schemas-microsoft-com:office:office#Control";
//this is the list GUID of the second list that you are picking up the filtered data from
var lookupListName = "{99E28AFE-5643-4F69-AF52-DE3DB3D563D2}";
//this is theGUID of the view in that second list – create a view that has ID and the items you wish to filter (in that order)
var lookupViewName = "{1D516144-CA30-4BCD-A742-E8F2BB8EA863}";
var listEl = document.getElementsByName(controlName)
// — emptying the field that you want to filter
if(listEl.length>0)
{
listEl(0).innerHTML = "";
// — getting the filtered lookup filterField is the name of the other field that the filtered list is dependant on (i.e. mine picks controls that are relevant to the workstream I have selected)
var filterField = "Workstream";
var filterValue = fieldValue;
var reqstring = siteName + "/_vti_bin/owssvr.dll?CS=109&XMLDATA=1&RowLimit=0&List=" + lookupListName + "&View=" + lookupViewName +"&FilterField1=" +filterField + "&FilterValue1=" + filterValue;
var req = new ActiveXObject("MSXML2.XMLHTTP");
req.open("GET",reqstring,false);
req.send();
// — loading response in XML Document
var doc = new ActiveXObject("MSXML2.DOMDocument");
doc.loadXML(req.responseText);
var data = doc.documentElement.childNodes(1);
//this loops through the items picked up from the list and puts them in the filtered dropdown
for (i=0;i<data.childNodes.length;i++)
{
var optionText = data.childNodes(i).attributes(1).value;
var optionValue = data.childNodes(i).attributes(0).value;
var opt = document.createElement("OPTION");
listEl(0).options.add(opt);
opt.innerText = optionText;
opt.value = optionValue;
}
}
}
</script>
<script language="javascript">
var workstream1 = document.forms[0].elements["urn:schemas-microsoft-com:office:office#Workstream"];
function getCA_onclick()
{
alert("The Control dropdown will now be repopulated, please select the correct one");
var chosen = workstream1.options[workstream1.selectedIndex].text;
RepopulateList(chosen);
}
</script>
I was trying to come up with an idea that would make filtered lookups so that only a select number of items in a lookup would appear. For example if you had non-active data in a lookup and only wanted to be able to select from the active ones, but you obviously couldn't delete the data from that lookup as it would appear in old linked items.
The added problem is that the users were adding the data from excel rather than uploading the new form (I had already written some suitable code for this).
Anyway, with this in mind I thought the following might come in useful for someone else. It is an excel spreadsheet that has the lookups built in and those lookups are linked to the site although the main list is not linked to the site (because then you couldn't choose where the lookups are selected from) and the data needs to be pasted in in datasheet view.
The lookups themselves would need to be linked exports from the look-up lists. You will firstly need to set up a filtered view of the data you wish to see in your lookup. Export this particular view to your spreadsheet and then use it as your lookup for that row of data (use data validation). When the spreadsheet opens the data would need to be synchronised with the list. This could be done by writing a macro that went through and synchronised them all. It may be necessary to turn macros on for the person who is running them. You can set up the spreadsheet to run the macros on opening.
Then you have a list that looks up to only the data you want it to.
Code for automatically running the macro on loading the sheet:
Private Sub Workbook_Open()
Run ("Synch_Data")
End Sub
Code for synchronising the lists:
Sub Synch_Data()
Sheets("Data").Select
Range("BA2").Select
ActiveSheet.ListObjects("List1").UpdateChanges xlListConflictDialog
Sheets("GapTypes").Select
Range("B2").Select
ActiveSheet.ListObjects("List1").UpdateChanges xlListConflictDialog
Sheets("Data").Select
Range("A1").Select
End Sub
You can have a personalised navbar for each person by creating a list of the links and then entering the links for each person that you want to see in the navbar. Create a dataview that mimics whichever navbar you wish to have personalised (for example you can insert a row next to the top navbar, hide that and then customise your list view to look like that.) If you have view only my own switched on then each person will see their own navbar selections. The downsides are that if you are an admin you will see multiple navbars (unless you set maximum number of items to be 1) and you either have to enter the data as that person or get them to enter it themselves.
ΓΏ
Posted by lishmanm
No Comments »
I have often thought it a bit strange that you cannot total a calculated field, particularly when it is a number. I managed to acheive this a while ago but had forgotten how I did it so now I am going to put in down in writing so that I don't forget!
You need to change the view to a datasheet one in Frontpage. Then go to the code and find the ??? that ends the display of all the data. Between that and the ??? enter another row and the required number of table cells.
Then add the xsl code that will sum that field – in my case this makes the xml like this:
For some reason I don't seem to have the option of formatting this as a number in FrontPage so I guess I will need to do that in the XSL as well.
When adding a custom link bar through FrontPage it basically just doesn't appear on the page in IE. Can't yet figure out why not.
We are having problems when some external uses (extranet site with SSL) are clicking submit on a form. Basically they just get a blank page with the URL http://server/site/_vti_bin/owssvr.dll?CS=109 - I assume this is something to do with their IE settings being on possibly too high a security setting but am not sure at the moment. Maybe someone else has had this problem.
Have been out for a couple of months with a back problem and subsequent operation but am getting back into things now. There was a useful webcast whilst I was off showing the power of the dataview web part:
which had a couple of really useful things in. Maybe I am being blind but I can't see how you can rerun this webcast from this page…
One thing was passing parameters through to the dataview which I think is also covered in someone else's blog and there are details of this here:
http://support.microsoft.com/?id=831093
I've now used this a couple of times and it's really cool – for example if you want to pass 2 dates through to a calendar and only show the entries between those two dates.
I have now been off work for 5 weeks but have been trying to keep in touch with what is going on in the Sharepoint world!
Now I just have to stop being superstitious as all is happening on Friday 13th – I have an appontment with the consultant finally and my house sale should be completed on that day – it could all go horribly wrong!!