Moss: Kazi Mfano - Desturi Takwimu Aina ya

Biashara Igizo:

Biashara kote utekelezaji wa MOSS kwa kampuni ya viwanda na 30+ maeneo na dazeni chache idara ya ushirika.

Biashara Lengo:

Licha ya wingi wa vikundi vya biashara (idara, maeneo, nk), data fulani lazima iimarishwe katika ngazi ya kimataifa. Kwa mfano, mamlaka bwana orodha ya maeneo yote ya kimwili ya kampuni (e.g. viwanda vya, ghala maeneo, mauzo ya ofisi) lazima iimarishwe katika eneo la kati.

Tatizo kiufundi:

Jamii biashara ilikuwa kutekelezwa kwa kutumia makusanyo tovuti mbalimbali. Sisi ingekuwa walipenda kuunda orodha ya mamlaka ya maeneo ya kimwili katika orodha desturi WSS. Kisha, wakati sisi alihitaji kuwa na safu katika aina maudhui (au safu aliongeza kwa orodha au doc ​​maktaba) kwamba zilizomo ushirika maeneo, we would create a column using the "lookup" datatype na uhakika na orodha hii bwana.

Kwa bahati mbaya, lookup datatypes must access a source list "locally" maana ya kwamba orodha yetu mamlaka haiwezi span makusanyo ya tovuti.

Kiufundi Solution:

Kutekeleza mpya data desturi ya aina kutekelezwa kwa kuzingatia SPField na kuwakilishwa kama DropDownList katika UI ambaye ListItems populate kutoka orodha WSS bwana.

Sisi aliumba mpya tovuti ukusanyaji kuitwa "http://localhost/EnterpriseData". Kuna, we created a custom list named "Corporate Locations". This list just uses the standard "Title" shamba na vyenye orodha ya maeneo halisi ya ushirika.

Moja ifuatavyo hatua kadhaa za kipekee ya kujenga data desturi aina katika WSS. Wao ni:

  1. Kufafanua darasa ambayo hurithi kutoka SPField (mtu anaweza kurithi kutoka maeneo mengine kama inavyotakiwa).

Hapa ni kwamba kanuni kwa ajili ya:

umma darasani XYZZYCorporateLocationField : SPFieldText
{
umma XYZZYCorporateLocationField
(SPFieldCollection mashamba ya, string typeName, string displayName)
: msingi(mashamba ya, typeName, displayName) { }

umma XYZZYCorporateLocationField
(SPFieldCollection mashamba ya, string displayName)
: msingi(mashamba ya, displayName) { }

umma override BaseFieldControl FieldRenderingControl
{
kupata
{
BaseFieldControl control = mpya XYZZYCorporateLocationFieldControl();
control.FieldName = hii.InternalName;
kurudi control;
} //kupata
} // fieldrenderingcontrol

umma override string GetValidatedString(kitu thamani)
{
kama (hii.Required || value.ToString().Sawa na(Kamba.Tupu))
{
kutupa mpya SPFieldValidationException ("Department is not assigned.");
}
kurudi msingi.GetValidatedString(thamani);
} // getvalidatedstring

} // XYZZYCorporateLocation

  1. Kufafanua darasa lingine kwamba kurithi kutoka kudhibiti shamba msingi, kama katika:

umma darasani XYZZYCorporateLocationFieldControl : BaseFieldControl
{
kulindwa DropDownList XYZZYCorporateLocationSelector;

kulindwa override string DefaultTemplateName
{
kupata
{
kurudi "XYZZYCorporateLocationFieldControl";
}
} // DefaultTemplateName

umma override kitu Thamani
{
kupata
{
EnsureChildControls();
kurudi hii.XYZZYCorporateLocationSelector.SelectedValue;
} // kupata
kuweka
{
EnsureChildControls();
hii.XYZZYCorporateLocationSelector.SelectedValue = (string)hii.ItemFieldValue;
} // kuweka
} // override object Value

kulindwa override utupu CreateChildControls()
{

kama (hii.Field == null || hii.ControlMode == SPControlMode.Kuonyesha)
kurudi;

msingi.CreateChildControls();

hii.XYZZYCorporateLocationSelector =
(DropDownList)TemplateContainer.FindControl("XYZZYCorporateLocationSelector");

kama (hii.XYZZYCorporateLocationSelector == null)
kutupa mpya Ubaguzi("ERROR: Cannot load .ASCX file!");

kama (!hii.Page.IsPostBack)
{

kutumia (SPSite site = mpya SPSite("http://localhost / enterprisedata"))
{
kutumia (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists["Corporate Locations"];

foreach (SPItem XYZZYCorporateLocation katika currentList.Items)
{
kama (XYZZYCorporateLocation["Title"] == null) kuendelea;

string theTitle;
theTitle = XYZZYCorporateLocation["Title"].ToString();

hii.XYZZYCorporateLocationSelector.Items.Add
(mpya ListItem(theTitle, theTitle));

} // foreach

} // using spweb web = site.openweb()
} // using spsite site = new spsite("http://localhost/enterprisedata")

} // if not a postback

} // CreateChildControls

} // XYZZYCorporateLocationFieldControl

kanuni juu ya kimsingi kutekeleza mantiki kwa populating DropDownList na maadili kutoka orodha WSS desturi iko katika http://localhost/enterprisedata and named "Corporate Departments".

Mimi inavyoelezwa madarasa wote katika faili moja. Cs, ulioandaliwa yake na kuiweka katika GAC (nguvu required, bila shaka).

  1. Kutekeleza template kudhibiti (.ascx) kama inavyoonekana:

<%@ Kudhibiti Lugha="C#" Kurithi="Microsoft.SharePoint.Portal.ServerAdmin.CreateSiteCollectionPanel1,Microsoft.SharePoint.Portal,Toleo = 12.0.0.0, Utamaduni = upande wowote,PublicKeyToken = 71e9bce111e9429c" compilationMode="Always" %>
<%
@ Kujiandikisha Tagprefix="wssawc" Eneo la majina="Microsoft.SharePoint.WebControls" Bunge="Microsoft.SharePoint, Toleo = 12.0.0.0, Utamaduni = neutral, PublicKeyToken = 71e9bce111e9429c" %> <%@ Kujiandikisha Tagprefix="SharePoint" Eneo la majina="Microsoft.SharePoint.WebControls" Bunge="Microsoft.SharePoint, Toleo = 12.0.0.0, Utamaduni = neutral, PublicKeyToken = 71e9bce111e9429c" %>
<SharePoint:RenderingTemplate ID="XYZZYCorporateLocationFieldControl" runat="server">
<Kigezo>
<ASP:DropDownList ID="XYZZYCorporateLocationSelector" runat="server" />
</Kigezo>
</
SharePoint:RenderingTemplate>

hapo juu ni kuokolewa katika c:\mpango files kawaida files Microsoft pamoja mtandao kompyuta upanuzi 12 controltemplates.

  1. Hatimaye, sisi kujenga faili XML kuokoa katika saraka ..... 12 XML. Hii ni CAML kwamba amefafanua yetu data desturi aina na kwa mfano wangu, inaonekana kama hii:

<?xml toleo="1.0" encoding="UTF-8" ?>
<
FieldTypes>
<
FieldType>
<
Shamba Jina="TypeName">CorporateLocations</Shamba>
<
Shamba Jina="ParentType">Nakala</Shamba>
<
Shamba Jina="TypeDisplayName">Corporate Locations</Shamba>
<
Shamba Jina="TypeShortDescription">All XYZZY Corporate locations including manufacturing or other facilities.</Shamba>
<
Shamba Jina="UserCreatable">KWELI</Shamba>
<
Shamba Jina="ShowInListCreate">KWELI</Shamba>
<
Shamba Jina="ShowInDocumentLibraryCreate">KWELI</Shamba>
<
Shamba Jina="ShowInSurveyCreate">KWELI</Shamba>
<
Shamba Jina="ShowInColumnTemplateCreate">KWELI</Shamba>
<
Shamba Jina="FieldTypeClass">Conchango.XYZZYCorporateLocationField, XYZZYCorporateLocationField, Version = 1.0.0.0, Utamaduni = neutral, PublicKeyToken=b0b19e85410990c4</Shamba>
<
RenderPattern Jina="DisplayPattern">
<
Kubadili>
<
Expr>
<
Safu />
</
Expr>

<Uchunguzi Thamani=""/>

<Default>
<
HTML>
<![CDATA[
<span style="color:Red"><b>]]>
</
HTML>

<
Safu SubColumnNumber="0" HTMLEncode="KWELI"/>

<HTML><![CDATA[</b></span>]]></HTML>

</
Default>
</
Kubadili>

</
RenderPattern>
</
FieldType>
</
FieldTypes>
This XML file adds the custom data type to the WSS "library" na mechi yake juu ya mkutano GAC'd.

Baada ya kuhamia hizi bits wote katika mahali, iisreset kwenye server na ni lazima kila kuanza kufanya kazi vizuri.

3 mawazo juu ya "Moss: Kazi Mfano - Desturi Takwimu Aina ya

  1. Alejandro
    Hi Paulo,
    Awali ya yote, shukrani kwa ajili ya makala ya, kwa sababu ni ya kuvutia sana. Swali moja tu;
    Unajua kama ni posible kutoa usahihi desturi shamba aina katika mtazamo datasheet ya orodha?
    Kwa sababu kila desturi ya aina shamba mimi kujenga ni umeonyesha kama kusoma tu katika mtazamo datasheet (na MSDN, kwa mfano, hana msaada kwangu sana :-S).
    Shukrani
    Kujibu
  2. Lyndsay

    I am attempting to implement your solution. However I instead of DropDownList, I only have the option for a DropDownChoiceList. Do you happen to know how to add items to a DropDownChoiceList? Sisi ni kutumia SharePoint 2007 SP1 na studio ya Visual 2005 SP1.

    Kujibu

Kuondoka Reply

Anwani yako si kuchapishwa. Mashamba required ni alama *