How to find visible list columns in Sharepoint?

I am using the SharePoint object model. I have not seen a way to do this in the MSDN documentation ...

+3
source share
2 answers

I have finished this route. Variety brute force, but it works:

        SPList l = SPContext.Current.Web.Lists[new Guid(ddl_Lists.SelectedValue)];
        List<string> visFields = new List<string>();
        foreach (SPField field in l.Fields)
        {
            if (!field.Hidden)
            {
                visFields.Add(field.Title);
            }
        }

Hope this helps someone!

+2
source

The fields you see are based on the current view. Use SPList. DefaultView to get the default view. You can also use SPList. Views to get any view.

For the SPView class, you can use the ViewFields property to get view fields.

+5
source

Source: https://habr.com/ru/post/1789927/


All Articles