Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
  1. First Group By is not working (however the second file subcategory Group By works)
  2. The OrderBy is not working
  3. Show all items without folder is not working

Any ideas??

private static void CustomView(SPWeb web, SPList spList)
{
    SPViewCollection oViewCollection = spList.Views;
    string strViewName = "Custom_View";
    System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection();
    viewFields.Add("File Type");
    viewFields.Add("Name");
    viewFields.Add("File Date");
    viewFields.Add("File Number");           
    //string strQuery = "<OrderBy><FieldRef Name=\"LinkFilenameNoMenu\" /></OrderBy>";  //works

    string strQuery = "<GroupBy Collapse=\"TRUE\" GroupLimit=\"100\">" +
                        "<FieldRef Name=\"File Category\"/>" +
                        "<FieldRef Name=\"File Subcategory\"/>" +
                        "</GroupBy>" +
                        "<OrderBy>" +
                        "<FieldRef Name=\"LinkFileName\"/>" +
                        "</OrderBy>";


    oViewCollection.Add(strViewName, viewFields, strQuery, 100, true, true);    
    spList.DefaultView.Update();
    spList.Update();

    SPView view = spList.Views["Front_Page"];
    view.Scope = SPViewScope.Recursive;
    spList.Update();
}
share|improve this question
add comment

1 Answer 1

Problem Solved.

  1. Used LinkFilenameNoMenu for order by and it works.
  2. Used File_x0020_Category instead of File Category in group by and the group by working.
  3. Added view.update() to make recursive working.

Thanks

share|improve this answer
add comment

Your Answer

 
discard

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