我在SharePoint中有一个自定义列表(特别是MOSS 2007).一个字段是是/否复选框,标题为"任何缺陷?" 另一个字段是"关闭"并命名已关闭票证的人.
如果没有缺陷,那么我希望机票自动关闭.如果有,那么"关闭"字段应该在以后填写.
我想我可以像这样设置"已关闭"的计算默认值:
=IF([Any defects?],"",[Me])
Run Code Online (Sandbox Code Playgroud)
但SharePoint抱怨我引用了一个字段.我认为这是有道理的; 首次打开新列表项以进行输入时,将触发默认值,并且尚未在任何字段中显示任何值.
我知道可以根据列值创建计算字段,但在这种情况下,以后不能编辑该字段.
有没有人有任何建议如何实现我想做的事情?
是否可以使用"OnSubmit"类型事件,允许我在保存列表项时执行某些代码?
谢谢.
在页面中包含内容编辑器Web部件(newform.aspx/editform.aspx)并使用jQuery(或只是普通的javascript)来处理默认值的设置.
编辑:一些示例代码:
在列表newform.aspx中,包含对jquery的引用.如果查看html代码,您可以看到每个输入标记都根据字段的GUID获取id,并且标题设置为字段显示名称.
现在,使用jquery我们可以使用jQuery选择器获取这些字段,如下所示:
按标题:
$("input[title='DISPLAYNAMEOFFIELD']");
Run Code Online (Sandbox Code Playgroud)
通过id(如果你知道该字段的内部guid,破折号将被下划线替换:
// example field id, notice the guid and the underscores in the guid ctl00_m_g_054db6a0_0028_412d_bdc1_f2522ac3922e_ctl00_ctl04_ctl15_ctl00_ctl00_ctl04_ctl00_ctl00_TextField
$("input[id*='GUID']"); //this will get all input elements of which the id contains the specified GUID, i.e. 1 element
Run Code Online (Sandbox Code Playgroud)
我们将它包装在ready()jQuery 的函数中,因此只有在文档完全加载时才会进行所有调用:
$(document).ready(function(){
// enter code here, will be executed immediately after page has been loaded
});
Run Code Online (Sandbox Code Playgroud)
通过组合这两个,我们现在可以将您的下拉列表onchange事件设置为以下内容
$(document).ready(function(){
$("input[title='DISPLAYNAMEOFFIELD']").change(function()
{
//do something to other field here
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
51479 次 |
| 最近记录: |