0

I have a library in SharePoint 2010. The library has folders, each item in the library, including the folder, are tagged with a number (separate column).

When I do an 'OrderBy' the column, the ordering works, however it groups the elements by content type.

                       <Where>
                            <And>
                                <Or>
                                    <Geq>
                                        <FieldRef Name='_ModerationStatus' />
                                        <Value Type='ModStat'>0</Value>
                                    </Geq>
                                    <BeginsWith>
                                        <FieldRef Name='ContentTypeId' />
                                        <Value Type='ContentTypeId'>0x0120</Value>
                                    </BeginsWith>
                                </Or>
                                <And>
                                    <Geq>
                                        <FieldRef Name='OrderBy' />
                                        <Value Type='Number'>1</Value>
                                    </Geq>
                                    <Neq>
                                        <FieldRef Name='ID' />
                                        <Value Type='Counter'>1</Value>
                                    </Neq>
                                </And>
                            </And>
                        </Where>
                        <OrderBy>
                            <FieldRef Name='OrderBy' Ascending='True' />
                        </OrderBy>";

The ordering works, but it always groups the results by content type prior to ordering. See the example below, the folders are group and ordered, and the files are grouped and ordered.

Name OrderBy

FolderA 2

FolderB 3

FolderC 4

FileA 1

FileB 5

Is there anyway to solely order the items in the list by the 'OrderBy' column only?

0

Teddy,

Please have a look at List View sort folders and files together

Excerpt from the answer:

For your question, I need to tell you it was designed to be. In our operating system they also display in the same way.

Here is a workaround, you can have a try if it can meet your demand.

There is a feature called "Group by" and you can find it when you create or modify a view. Here you can make the files and folders group by Title that items have same title would be included to a same group.

Now you can make the items sort by Title and they will display as groups.

And here is how to Group By using CAML
How to use GroupBy in CAML query

 <GroupBy Collapse="TRUE">
   <FieldRef Name="Title" />
 </GroupBy>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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