开发者

sharepoint moss 2007 add column with javascript

We use MOSS 2007, and I have a document library with several document templates in it. When someone clicks the document template (for example .dotx), the templates is opened. But I want it working so that a new document is opened based on the template.

I can do this with the New button in the toolbar above the list, but I do not like this, and it is not as easy to use for the SharePoint users.

There is a workaround, the user has to click at the right side of the name of the template, then go to the menu 'Send To' and choose 'Download a Copy', in the popup they have to choose 'Open' to create a new document based on the template.

I did found some javascript that can be used to create a new document based on a template:

<a href="javascript:createNewDocumentWithProgID('[template path],
  '[default save dir]', 'SharePoint.OpenDocuments', false)">
   Create new document
</a>

I really want to use this, but is there a way to add this script to a link in a column in the document library list?!? I tried a new column with type Hyperlink, but an URL starting with 'javascript:....' is not a valid url according to SharePoint.

Or is there another开发者_JS百科 way to accomplish this, a column in an existing list with some text, and if you click on that text, a document will be created based on the template.


Look into a computed column. You can use his to generate html code


Maybe you should try a Multiple Lines of text column with your HTML link inside of it?


Finally i did get it to work with the solution described in the link http://blog.pathtosharepoint.com/2008/09/01/using-calculated-columns-to-write-html and thanks to brian brinley

Added a Content Editor Web Part to the page where the document list is added. Put in the source code downloaded from: http://pathtosharepoint.com/Downloads/

-> Topic: HTML Calculated Columns -> TextToHTML-V2.1.1 - (Full version)

The CEWP should be places underneath the Document Library, then add a column to the library (a simple text column), and add the following text to that column:

<DIV><a href="javascript:createNewDocumentWithProgID('[http template path]'
, '[http: default same location]', 'SharePoint.OpenDocuments', 
false)">New document</a></DIV>

And you will get a link named New document, that opens new document based on the template.

Disadvantage 1:
I think this can be made better by using a calculated field, but I did not get the URL of the current document into a calculated field.

Disadvantage 2:
The new column is not also a property of the document. When opening a Word 2010 template this way, the 'Document Properties - Server' bar is shown and you can alter the content of the field that contains the text

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜