While working on one of the requirement in my project , I need to show the files in Root Folder of Document library only not from child folders within it.
Through "Folder" option in default view, I can only set to show the folder or show files without folder.
But through code we will get all the files in root folder as well as in child folder also.
To resolve this, you need to use Scope="FilesOnly" for the ViewAttributes property of the SPQuery.
SPList list = _oWeb.Lists["Library Name"];
SPQuery spQuery = new SPQuery();
spQuery.ViewAttributes = "Scope=\"FilesOnly\"";
SPListItemCollection items = list.GetItems(spQuery);
Thursday, June 23, 2016
You can do it by setting LinkToItem="True" attribute in the default view for list or document library.
You can use SharePoint Designer for this, open your list or library and then your view and make change like shown below:
<FieldRef Name="CustomLink" LinkToItem="TRUE"/>
If you want to set any specific URL, then you can create a "calculated column" by using a formula with existing column and use this new calculated column in above example.
=CONCATENATE("http://YourDomain/sites/SiteCollection/Lists/ListName/Forms/<<any form name>>.aspx?ID=",ID)