Revision #2

You are currently reviewing an older revision of this page.
Go to current version

LETS IMPROVE OUR SHAREPOINT EXPERIENCE.. i am your party starter..


Sharepoint 2010 is a powerfull product, but there are times one feels limited. Thats a bold saying, but when you've worked with Sharepoint i'm sure you wished there where options to sum a table. Or that you  wanted to have more control on how things graphically where shown. You know all the data is in it but  sometimes its hard to display it.

What i will write down here in this article is how to summerize a table, and create a graphic based on it. I will also explain how to do it, we're going to break open sharepoint so you can do finally what you want to do with it. While we  wont need more access then well basically Sharepoint Designer, or using only the web browser is possible too!. But with SPD (Sharpoint designer)  we could do a bit more.

I will keep  in mind that most of you dont code, or are new to sharepoint, jscript CAML Jquery etc etc.
You should know HTML tags, i am not going to explain those.

I would advice to use some kind of editor to write Jscript in, for example Notepad++ / Editra  / ... etc
Also to test locally jscript its handy to have locally on your client pc a webserver
A real small one can be downloaded here (read its small manual also) http://www.ritlabs.com/tinyweb/

Our client interaction.

A thing to note is that we do user based; or better call it triggered interaction with sharepoint. If we have a part on a webpage that we would like to update preferably we would only like to update that part and not reload the whole page. So we need a trick to do just that. Lets make a litle webpage called index.html and place it in the c:\www\root   folder from tinyweb

01.<html><head></head><body
02.<div id="MyStuff">
03.You will see me <br>
04.When nothing has been pressed
05.</div>
06. 
07.<script type="text/javascript">
08.function changeText(){
09.    document.getElementById('MyStuff').innerHTML = '<b>WOW you changed me !, this is funny</b>';
10.}
11.</script>
12.<input type='button' onclick='changeText()' value='Change Text'/>
13.</body></html>

Note that instead of having the <div id="mystuff">  tag, also <from id=title> could be used. However the webparts for  customized HTML in Sharepoint wont accept that so.. so that's why we use <div title=....> instead. Well saved it in c:\www\root\ ?
Then try it locally, browse to http://127.0.0.1/index.html if you installed tinyweb.

We just learned to change a part of a html page, by user action. And well basically this new text was created by some javascript function that changed the DOM parts of a HTML page. It was simple text display, but could have been an image or calculation.. from the moment you clicked it!
Hmm calculations too.... remind that we will use it soon.

Placing your javascripts on sharepoint

Although its maybe a bit silly the previous page we made we could put its script part on sharepoint to. Note that it  would be a fragment for a normal .aspx based page. .aspx is a complex HTML type on which sharepoint is based, if your interested some informative information can be found here.

Well our code only will  go inside another aspx page.. kinda cool huh ?...
Let us simply just copy from <div id="MyStuff"> ... to ... <input type='button' onclick='changeText()' value='Change Text'/>
And save that as myfirst.js
Its actually a bit more then only script since some text before and after the <script...> tags is used also, but that's OK, Sharepoint wont complain about that.


I admit i'm a lazy writer, so to add our peace of code to a page follow this guys article, but note that your file isnt text.txt like in his example. Also note that he uses the "Site Assets library" to store the script. Well it could be anywhere but sure normal users can only read it.. ! (read about sharepoint permissions here). Scripts can be powerful and you wouldn't want someone to mesh up your script to create havoc !.

Useful script parts for Sharepoint

Instead of writing a huge script where i will combine everything i think its better for your understanding. To start thinking in scripts as functions you need to combine, and to adjust yo your own situation. So i will keep my script  parts relatively small, for sake of understanding and simplicity.

reading a list


I will continue writing this article later make it a favorite if you wish
I hope to finish it soon (so i have a good reminder of all i did the past days).
This will cost me a few evenings to write, for now its time to sleep for me.