Posts mit dem Label ListView werden angezeigt. Alle Posts anzeigen
Posts mit dem Label ListView werden angezeigt. Alle Posts anzeigen

Montag, 7. November 2011

Adding a Taxonomy Field

TermStore termStore = session.DefaultKeywordsTermStore;
Group group = termStore.GetSiteCollectionGroup(this.site);
TermSet termset = group.TermSets[0];

TaxonomyField field = (TaxonomyField)list.Fields.CreateNewField("TaxonomyFieldType", name);

field.Required = required;
field.Description = description;
field.SspId = termStore.Id;
field.TermSetId = termSet.Id;
field.AllowMultipleValues = allowsMultiple;
field.EnforceUniqueValues = enforceUniqueValues;
field.IsPathRendered = renderpath;
// field must be indexed to enfoce unique values!
field.Indexed = enforceUniqueValues;
Term anchor = termSet.GetTermByPath(anchorPath);
field.AnchorId = anchor.Id;
field.NoCrawl = noCrawl;

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomysession.aspx

http://www.communardo.de/home/techblog/2011/10/18/sharepoint-2010-der-termstore-und-der-priviligierte-nutzer/


Was wird durch die folgende Methode veranlasst?
Möglicher Fix für Probleme nach Content Deployment
// Resync the taxonomy hidden list to make sure it is update-to-date
TaxonomySession.SyncHiddenList(site);

DisplaceOnUpgrade
Optional Boolean. If a field definition already exists for the field, TRUE to force updates to field properties with the values that are specified in this field definition.

http://www.sharepointconfig.com/2011/03/the-complete-guide-to-provisioning-sharepoint-2010-managed-metadata-fields/

Mittwoch, 16. Februar 2011

Adding a ListViewWebPart to Page


[UPDATE 01.Feb.2012: wp.ViewGuid = string.Empty gilt nur für 2007]
Hier eine Erklärung für 2010
[ENDUPDATE]
[UPDATE: Set View to "Summary View"]


using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;

// Get a reference to a web and a list
SPSite site = new SPSite("http://localhost:8000");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Contacts"];

// Instantiate the web part
ListViewWebPart wp = new ListViewWebPart();
wp.ZoneID = "Left";
wp.ListName = list.ID.ToString("B").ToUpper();
// wp.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();
// Set the ViewGuid to string.Empty to get the "Summery View"
// including the "Add New Item"-Button
// Thanks to sadomovale
wp.ViewGuid = string.Empty;
// Get the web part collection
SPWebPartManager mgr = new SPWebPartManager("default.aspx", Storage.Shared);
// Add the web part
coll.Add(wp); 


Dienstag, 26. Oktober 2010

How to Add a ListViewWebPart to a Publishing Page

neuer Versuch das ListViewWebPart zu verstehen







Adding a ListViewWebPart to a "Publishing Page" is easy.
Create a Instance of a SPWebpartmanager, with the relevant Page-Url and get the WebPartCollection.
Create a new ListViewWebPart instance, set the ListID to the ID of SPList object you want to show.
Provide a ViewID to the Webpart and add it to the Collection, including the ID of the WebPartZone and a Sequence Number for the order within the zone.


Showing a Document Library including the "Add document" Button  isn't easy at all.
In the UI it is just a click away -> Edit WebPart ->  select ToolbarType and set it to "Summary ToolBar".
I think its almost default in UI.

[UPDATE: see adding-listviewwebpart-to-page]
If you want to use OM to add this WebPart you have to use a "hack" by modifying the schema of the used view. Which can affect also the view of the document library.
Jalil Sear describes it at his blog listviewwebpart-programatically-setting-the-toolbartype-property/


I worked around this issue by adding my own "Add Document" button to the page, having the possibillity of positioning, using audiences and renaming.