自定义字段类型与FCKeditor结合
来源:互联网 发布:网络技术交流论坛51zm 编辑:程序博客网 时间:2024/04/30 15:03
LitwareFieldTypes
实现:FCKeditor这个多行文本编辑器,作为字段类型,添加到列表的栏里
问题:因为创建的这个字段类型是继承SPFieldMultiLineText,所以它的长度不能超过255字符
成功部署在242上,如图
1、创建栏位,选择“文本编辑器”类型
2、看到“说明(文本编辑器) 文本编辑器”
3、新建页面的显示
解决问题:
法一:修改数据库
SELECT tp_Fields
FROM allLists
WHERE tp_ID = 'a6b094e6-8b
法二:修改XML文件
在fldtypes_Litware.xml中:
<?xml version="1.0" encoding="utf-8" ?>
<FieldTypes>
<FieldType>
<Field Name="TypeName">CompanySize</Field>
<Field Name="ParentType">Note</Field>
<Field Name="TypeDisplayName">文本编辑器</Field>
<Field Name="TypeShortDescription">文本编辑器</Field>
<Field Name="UserCreatable">TRUE</Field>
<Field Name="ShowInListCreate">TRUE</Field>
<Field Name="ShowInSurveyCreate">TRUE</Field>
<Field Name="ShowInDocumentLibraryCreate">TRUE</Field>
<Field Name="ShowInColumnTemplateCreate">TRUE</Field>
<Field Name="FieldTypeClass">LitwareFieldTypes.CompanySizeField, LitwareFieldTypes, Version=
<RenderPattern Name="DisplayPattern">
<Column/>
</RenderPattern>
</FieldType>
</FieldTypes>
注意:1、如果修改了fldtypes_Litware.xml,需要在列表设置中,删除旧的栏位,重新创建这个自定义类型的新栏位。这样修改才能生效。
2、<Field Name="ParentType">Note</Field> ,Note可以解决字段最大255个字符长度的问题,如果设置Text则字段最大长度为255
工程代码:
using System;
using System.IO;
using System.Security.Permissions;
using System.Text;
using System.Xml;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using FredCK.FCKeditorV2;
using System.Collections.Generic;
namespace LitwareFieldTypes
{
// example of creating a custom field type
public class CompanySizeField : SPFieldMultiLineText
{
/// <summary>
/// Override the field rendering control to use the custom TreeList control
/// </summary>
///
public override Microsoft.SharePoint.WebControls.BaseFieldControl FieldRenderingControl
{
get
{
BaseFieldControl control = new CompanySizeFieldControl();
control.FieldName = this.InternalName;
return control;
}
}
// Validate the string. If not valid, throw an SPFieldValidationException
//public override string GetValidatedString(object value)
//{
// if (this.Required || value.ToString().Equals(string.Empty))
// {
// throw new SPFieldValidationException("Company size not assigned");
// }
// return base.GetValidatedString(value);
//}
/// <summary>
/// Null constructor
/// </summary>
/// <param name="fields"></param>
/// <param name="fieldName"></param>
public CompanySizeField(SPFieldCollection fields, string fieldName)
: base(fields, fieldName) { }
public CompanySizeField(SPFieldCollection fields, string typeName, string displayName)
: base(fields, typeName, displayName) { }
}
// custom field type uses helper class to initialize and render control
public class CompanySizeFieldControl : BaseFieldControl
{
protected FCKeditor txtContent;
public override object Value
{
get
{
this.EnsureChildControls();
return this.txtContent.Value;
}
set
{
EnsureChildControls();
this.txtContent.Value = (string)this.ItemFieldValue;
}
}
protected override void CreateChildControls()
{
if (this.ControlMode == SPControlMode.Display)
{
base.CreateChildControls();
}
else
{
this.txtContent = new FCKeditor();
this.txtContent.BasePath = "/_layouts/fckeditor/";
this.txtContent.ToolbarSet = "Default";
this.txtContent.Width = new Unit("600px");
this.txtContent.Height = new Unit("300px");
this.txtContent.ID = "aa";
this.Controls.Add(this.txtContent);
}
}
}
}
- 自定义字段类型与FCKeditor结合
- FCKEditor与ext结合使用
- 从FCKEDITOR到ckeditor(二)----撰写自定义对话框,增加数学公式(与webEq的结合)
- 自定义字段(栏)类型
- django 自定义 字段类型
- DBUtils与C3P0结合--支持自定义字段映射和线程池
- DBUtils与C3P0结合--支持自定义字段映射和线程池
- MOSS2007的自定义字段类型
- JIRA更改自定义字段类型
- 开发自定义字段类型 sharepoint
- SQL 修改字段名 与字段类型
- 自定义列表字段类型(0)
- 自定义列表字段类型(1)
- 自定义列表字段类型(2)
- 自定义列表字段类型(3)
- SharePoint 2010 自定义 字段 类型--------省市区联动
- sharepoint 2013 开发自定义字段类型说明
- Pods:WordPress 自定义内容类型 字段 分类法
- 页面树形控件dhtmlxTree、mztreeview及xtree比较
- C function strtok()
- 年终回顾:08年SOA市场 硝烟正浓
- Hibernate懒加载策略
- 软件园里的流氓(11)
- 自定义字段类型与FCKeditor结合
- 在maven 2工程中加入iTextAsian支持
- 软件园里的流氓(12)
- C#中的多态性
- 让Editplus自动格式化css和js
- 什么是socket
- android 常用命令
- 软件园里的流氓(13)——完
- cmake相关