I was wondering if it was possible to modify the default document library view "All Documents " to include the "Checked Out To" column.
I need this change to apply to any existing document libraries as well as any created in the future.
You could modify the default document library, but it's not a good idea to modify any of the standard files that ship with SharePoint as future updates may remove your customisations (or worse, your customisations may prevent future updates).
A better idea would be to either create your own custom library definition and deploy it as a Feature, or simply create and modify a Document Library to suit, save it as a Template in the List Template Gallery, and use that in future for all new libraries. Toni's code will update any existing libraries.
You could use the following code to make the desired changes. It worked for me with similar requirements. In case you have a large site collection you might wanna try to break this and do it site by site or something. AFAIK code approach is the only option.
The sample below is C# Console App, but you could modify it to work as PowerShell script or something.
using(SPSite siteCollection = new SPSite("http://your_sitecollection_url/"))
{
foreach (SPWeb web in siteCollection.AllWebs)
{
using (web)
{
for (int i = 0; i < web.Lists.Count; i++)
{
SPList list = web.Lists[i];
if (list is SPDocumentLibrary && list.Fields.ContainsField("Checked Out To"))
{
foreach (SPView view in list.Views)
{
if (view.Title == "All Documents")
{
if (!view.ViewFields.Exists("CheckoutUser"))
{
Console.WriteLine("Updating \"All Documents\" view for: {0}", list.DefaultViewUrl);
SPField field = list.Fields["Checked Out To"];
view.ViewFields.Add(field);
view.Update();
}
break;
}
}
}
}
}
}
}