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

As per title, is it possible (and how) to modify default view in code so that it display contents of the list grouped by one of it's columns?

I tried the following:

defaultView.Query = String.Format(@"<GroupBy collapse='true'>" +
                                          "<FieldRef Name='{0}' />" +
                                       "</GroupBy>", SPBuiltInFieldId.TaskDueDate);
defaultView.Update();

but this doesn't seem to work.

share|improve this question

1 Answer 1

There are couple of ways to do it. 1. Access the view's schema XML and modify the query XML inside this. This can be achieved through SharePoint object model. 2. Use designer, generate the XSLT for the webpart and change the query appropriately.

share|improve this answer
    
please see my edit. I have tried 1 and 2 doesn't look like it's to do in code? –  Sebastian Jun 28 '12 at 6:35
    
This seems to be fine, you might need to debug the code to check. Not able to comment by just looking at these two lines of code. –  Manju Jun 29 '12 at 3:29

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.