在大家对SPS文档库页面中的文档上下文菜单进行定制的时候,几乎免不了和两个很常见的变量打交道:ctx、itemTable,通过它们的某些属性,就能够得到相关文档的很多信息,供开发人员使用。但是它们到底一共有哪些参数呢?呵呵,已经有几个朋友表示过郁闷了,希望下面的文字能够让大家不再郁闷。
ctx变量是一个名为ContextInfo的自定义类型,它的完整定义可以在ows.js的第10031行找到,如下:
function ContextInfo() { this.listBaseType = null; this.listTemplate = null; this.listName = null; this.listUrlDir = null; this.HttpPath = null; this.HttpRoot = null; this.imagesPath = null; this.PortalUrl = null; this.isWebEditorPreview = null; this.rootFolderForDisplay = null; this.isPortalTemplate = null; this.isModerated = false; this.recursiveView = false; this.displayFormUrl = null; this.editFormUrl = null; this.newFormUrl = null; this.ctxId = null; }
itemTable变量实际上就是一个Table类型的页面对象,但是它有一些额外自定义的属性,如下:
SourceUrl
COUId
FSObjType
DocIcon
FileType
HTMLType
FileDirRef
ServerUrl
ItemId
CTXName
Custom_ AddDocLibMenuItems函数有两个参数:m和ctx。
其中,
m 代表的是菜单这个对象本身;
ctx 则提供了关于这个Web请求的HTTP context信息。
真正添加菜单项的,就是下面的函数:
CAMOpt(m, strDisplayText, strAction, strImagePath)
其中strDisplayText是菜单项显示出来的名字;
strAction是点击菜单项时执行的javascript动作;
strImagePath是和这个菜单项关联的图片的路径。
CAMSep的作用是插入一条分隔条。
最后,函数的返回值是false。这就告诉系统,继续生成原来标准的菜单。
如果返回值是true,那么意味着原来的菜单项不会再被添加进来了。
这样,我们就可以实现自己重写整个菜单项了。