Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How do you with CAML provision a View to a already existing list? I know how to add views through list definitions.

share|improve this question
add comment

2 Answers

I think you can do like here : Specifying advanced webpart properties on a view in a custom module?

share|improve this answer
    
Im sorry, I think the correct term to use in my question is View, and not ListView, which I used. The Code you refer to instancitetes a XsltListViewWebPart. Which is something different from what I'm trying to achieve. –  Tim Jun 20 '12 at 16:22
add comment

You can't add a view to a list using the declarative model as you would in a list definition. The best way to do this would be in a Feature Receiver, using .NET code.

share|improve this answer
    
Sounds good, could you dive into some more details please? If I understood you correct I should write some CAML as in a list definition. But how do I apply It to a list through code? Isn't there a way to apply it declarative? –  Tim Jun 20 '12 at 16:34
    
No CAML. You'll need to write code. Get a new SPView, add the columns using myView.Add("Title"), for example. –  Derek Gusoff Jun 20 '12 at 16:45
    
OK, never mind, I may stand corrected. According to this blog, you might be able to add the CAML to the SPView's Query property.devx.com/dotnet/Article/31762 –  Derek Gusoff Jun 20 '12 at 16:48
    
Thank you, the blogs information looks promising. Will dive into it when I got some time over for it! –  Tim Jun 20 '12 at 17:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.