Override ListViews in all Lists.
-
mardi 1 mai 2012 18:31
Hello. First I want to say that I don't want to create custom webpart with custom list view, this is not a problem. I need to override all ListViews in all Lists in my SiteCollection. So for example you have custom list with ten different views. In all these views you can see field Title. But I need to hide this field for some users. So I think the only solution is to create some custom library and override some methods which generate all these views...Hmm....Can you please help me with this....
For example to hide fields in new/edit/display form I work with ListFieldIterator and IsFieldExclued...Hmm Is something like this for ListViews..
PS: I don't want to use any third party products I want to create this by my self or whit yoru help:) Thank you
Toutes les réponses
-
jeudi 3 mai 2012 06:33Modérateur
Hi,
You can remove a field from the list view in SharePoint 2010 using Client Object Model:
string siteUrl = "Yoursiteurl";
ClientContext clientContext = new ClientContext(siteUrl);
ListCollection collList = clientContext.Web.Lists;clientContext.Load(collList);
clientContext.ExecuteQuery();foreach (SP.List oList in collList)
{
SP.View view = oList.Views.GetByTitle("All items");
ViewFieldCollection viewFields = view.ViewFields;
viewFields.Remove("LinkTitle");view.Update();
clientContext.ExecuteQuery();
}Please note that the internal name of the Title-field is "LinkTitle".
Xue-mei Chang
TechNet Community Support
- Marqué comme réponse Xue-Mei Chang-MSFTModerator dimanche 13 mai 2012 13:09
- Non marqué comme réponse enti3333 jeudi 21 juin 2012 06:44
-
jeudi 3 mai 2012 07:48Hello.
Thank you very much for this solution but I need something else because I need override listview when it's generating. For example I want that field is visible only for administrators and for other users not. I need to override webpart class which generate these views...Hmm...Is this possible somehow. Thank you

