English 中文(简体)
共享习俗领域放任模式:通过多哥伦特地区排行
原标题:Sharepoint Custom Field Render pattern: loop through Sub Columns of Multiple Column field
  • 时间:2010-11-25 12:06:48
  •  标签:
  • sharepoint

我有一个来自<条码>的习俗股份领域。 实地的价值观似乎一样:

"页: 1column one value页: 1column two value页: 1column three value页: 1"

我想以单独一条线显示每个项目,删除。

页: 1

I checked this link http://msdn.microsoft.com/en-us/library/ms411957(office.12).aspx and found that this can be achieved by overriding the render pattern of the field like this

<RenderPattern Name="DisplayPattern" DisplayName="DisplayPattern">
  <Switch>
    <Expr>
      <GetVar Name="FreeForm"/>
    </Expr>
    <Case Value="TRUE">
      <Column/>
    </Case>
    <Default>
      <HTML>
        <![CDATA[ <DIV ALIGN=RIGHT> ]]>
      </HTML>
      <Column/>
      <HTML>
        <![CDATA[ </DIV> ]]>
      </HTML>
    </Default>
  </Switch>
</RenderPattern>

要想做到这一点,就必须预先确定分公司的数量,就我而言,可以确定。

因此,我需要在我的多个栏目中穿过每一个次栏目?

how can this be done ? thanks

问题回答

米纳斯

我在帮助你时不去气,这里是我的Xml和相关的班头的全部内容,供你参考。

<?xml version="1.0" encoding="utf-8"?>
<FieldTypes>
  <FieldType>
    <Field Name="TypeName">CountryStateCityAddress1Field</Field>
    <Field Name="TypeDisplayName">CountryStateCityAddress1Field</Field>
    <Field Name="TypeShortDescription">CountryStateCityAddress1Field</Field>
    <Field Name="ParentType">MultiColumn</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="FieldTypeClass">c0d4e972-cae4-4320-b13b-83ed0bf8cedc</Field>
    <RenderPattern Name="DisplayPattern">
      <Switch>
        <Expr>
          <Column />
        </Expr>
        <Case Value="" />
        <Default>
          <Column SubColumnNumber="0" HTMLEncode="TRUE" />
          <HTML><![CDATA[<br/>]]></HTML>
          <Column SubColumnNumber="1" HTMLEncode="TRUE" />
          <HTML><![CDATA[<br/>]]></HTML>
          <Column SubColumnNumber="2" HTMLEncode="TRUE" />
          <HTML><![CDATA[<br/>]]></HTML>
        </Default>
      </Switch>
    </RenderPattern>
  </FieldType>
  <FieldType>
    <Field Name="TypeName">EMailFieldTypeField</Field>
    <Field Name="TypeDisplayName">EMailFieldTypeField</Field>
    <Field Name="TypeShortDescription">EMailFieldTypeField</Field>
    <Field Name="ParentType">MultiColumn</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="FieldTypeClass">0e8a370a-0388-4b78-9e5c-ffbb8a481391</Field>
    <RenderPattern Name="DisplayPattern">
      <Switch>
        <Expr>
          <Column />
        </Expr>
        <Case Value="" />
        <Default>
          <Column SubColumnNumber="0" HTMLEncode="TRUE" />
          <HTML><![CDATA[<br/>]]></HTML>
          <Column SubColumnNumber="1" HTMLEncode="TRUE" />
          <HTML><![CDATA[<br/>]]></HTML>
          <Column SubColumnNumber="2" HTMLEncode="TRUE" />
          <HTML><![CDATA[<br/>]]></HTML>
        </Default>
      </Switch>
    </RenderPattern>
  </FieldType>
</FieldTypes>

标题:

namespace CustomFieldTypeAddress1
{
    [CLSCompliant(false)]
    [Guid("0e8a370a-0388-4b78-9e5c-ffbb8a481391")]
    public class EMailFieldTypeField : SPFieldMultiColumn 
    ...

namespace CustomFieldTypeAddress1
{
    [CLSCompliant(false)]
    [Guid("dc20d765-2d36-4396-83aa-f063166d8fcc")]
    public class EMailFieldTypeFieldControl : BaseFieldControl  
    ...

You could create a custom field control. See here and here for starting info on how to do this.

这使你在展示外地方面有很大的灵活性,但是这确实涉及更多的法典。

我也谈到由Xml档案中父母Type造成的同一问题。

在确定之前:

<Field Name="ParentType">Text</Field>"

在确定后:

<Field Name="ParentType">MultiColumn</Field>"

请参看

whan SP FieldMultiColumn 物体使用方法override Base FieldControl FieldRenderingControl 装载从继承的物体 Base FieldControl

因此,继承<代码>的物体 地面对有一种称为“方法”

protected override void RenderFieldForDisplay(HtmlTextWriter output){}

这样,你就可以使你控制适合你。

您可使用以下实例:

namespace SharePointTestApplication
{
    public class UserChoiceColumn:SPFieldMultiColumn
    {
        public UserChoiceColumn(SPFieldCollection fields, string fname)
            : base(fields, fname) { }

        public UserChoiceColumn(SPFieldCollection fields, string tname, string dname)
            : base(fields, tname, dname) { }

        public override BaseFieldControl FieldRenderingControl
        {
            get
            {
                BaseFieldControl ctr = new UserChoiceColumnControlType();
                ctr.FieldName = this.InternalName;
                return ctr;
            }
        }

        public override string GetFieldValueAsHtml(object value)
        {

            SPFieldMultiColumnValue mcv = new SPFieldMultiColumnValue(value.ToString());

            return string.Format("{0} , {1}",mcv[0],mcv[1]);
        }


    }

    public class UserChoiceColumnControlType : BaseFieldControl
    {
        #region Protected Members 

        protected TextBox TextBox1;
        protected TextBox TextBox2;

        #endregion

        protected override string DefaultTemplateName
        {
            get
            {
                return "UserChoiceColumnTemplate";
            }
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            TextBox1 = (TextBox)this.TemplateContainer.FindControl("TextBox1");
            TextBox2 = (TextBox)this.TemplateContainer.FindControl("TextBox2");
        }

        public override object Value
        {
            get
            {
                this.EnsureChildControls();
                SPFieldMultiColumnValue mcv = new SPFieldMultiColumnValue(2);
                mcv[0] = TextBox1.Text;
                mcv[1] = TextBox2.Text;
                return mcv;
            }
            set
            {
                this.EnsureChildControls();
                SPFieldMultiColumnValue mcv = (SPFieldMultiColumnValue)this.ItemFieldValue;
                TextBox1.Text = mcv[0];
                TextBox2.Text = mcv[1];
            }
        }

        **protected override void RenderFieldForDisplay(HtmlTextWriter output)
        {
            output.Write("hello world");
           // base.RenderFieldForDisplay(output);
        }**

    }
}




相关问题
SharePoint - Approaching Website Storage Limit Email

How can i go about changing the distribution list as well as the email text for the email that goes out to site collection admin when a site collection approaches it s size limit? Thanks for your ...

UI automated testing within SharePoint

I m looking for automated Functional Testing tools that can manipulate SharePoint sites, libraries, and documents thought the web interface. It needs to be extensible enough to handle any custom ...

Enable authorization on sitemap provider

I want to enable Authorization on the Site map provider. We have enabled anonymous access to the site and we want the Site map provider to be visible only to authorized users. I tried ...

SharePoint : web service permission error

I have a sharepoint site, and I am calling a standard sharepoint web service. I create the web service request like this : wsDws.Url = this.SiteAddress + @"/_vti_bin/Dws.asmx"; When I use ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签