默认全天事件检查/是 [英] Default All Day Event to Check/Yes

查看:57
本文介绍了默认全天事件检查/是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您的大力帮助.另一个问题.如何将日历上的全天事件"字段设置为默认为已选中/是"?如果我们可以将 All Day Event 的默认设置为 Yes,有没有办法隐藏时间字段(保留日期字段 - 只是没有时间字段)?我还想隐藏工作区"字段(如果可能).

Thanks for the great help. Another question. How do I set my "All Day Event" field on the calendar to default to "Checked/Yes?" If we can set the default on All Day Event to Yes, is there a way to hide the time fields (keep the date fields - just no time fields)? I'd also like to hide the "Workspace" field as well (if possible).

谢谢

戴夫

推荐答案

如果你有权在你的服务器上运行代码,我已经从一个控制台应用程序运行了它,它的工作就像一个魅力:

If you have access to run code on your server, I've run this from a console application and it worked like a charm:

using(SPSite site = new SPSite("http://yoursite"))
{
  using(SPWeb web = site.OpenWeb())
  {
    SPList list = web.Lists["your list name"];
    SPContentType ct = list.ContentTypes["Event"];
    SPFieldLink fieldLink = ct.FieldLinks["fAllDayEvent"];
    Type type = typeof(SPFieldLink);
    PropertyInfo pi = type.GetProperty("Default", BindingFlags.NonPublic | BindingFlags.Instance);
    pi.SetValue(fieldLink, "1", null);
    ct.Update();
  }
} 

来源:http://pholpar.spaces.live.com/blog/cns!2CD45589973F2849!131.entry

我们唯一需要做的修改是 SPFieldLink,示例使用 All Day Event,我们的列表使用 fAllDayEvent.

Only modification we had to make was the SPFieldLink, the examples uses All Day Event, our lists used fAllDayEvent.

我见过的唯一另一种方法是修改列表的 CAML(示例).

The only other way I've seen work is to modify the list's CAML (Example).

哦,我们使用 Javascript 隐藏了 Workspace 字段:

Oh, and we hid the Workspace field using Javascript:

<script language="javascript" type="text/javascript">

_spBodyOnLoadFunctionNames.push("hideFields");

function fc(FieldName) {
   var arr = document.getElementsByTagName("!");

   for (var i=0;i < arr.length; i++ ) {
      if (arr[i].innerHTML.indexOf(FieldName) > 0) { return arr[i]; }
   }
}

function hideFields() {
   control = fc("Workspace");
   control.parentNode.parentNode.style.display="none";
}
</script>

来源:http://sharepointsherpa.com/2008/08/26/sharepoint-2007-hiding-fields-on-newformaspx-and-editformaspx-the-easy-way/

这篇关于默认全天事件检查/是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆