views:

199

answers:

3

We are using WSS 3.0 and I was asked to see if users can set default views on a per-user basis. Is anyone aware of any method (programatic or through the GUI itself) to give users the ability to change default views on a per-user basis? The 30 minutes of googling and poking around in the administrative menus turned out to be unfruitful. If not, is this a feature of MOSS 2007?

+1  A: 

You probably want to look into audiences which is functionality in MOSS 2007.
Unfortunately it's not available in WSS 3.0

Here's a reasonable overview. User Profiles and Audience Targeting in SharePoint 2007

Bravax
+1  A: 

If you're working in WSS 3.0, you can programmatically swtich or modify views by using a webpart which gets the ListViewWebPart and modifies the query or view on the fly. Here is some sample code I am using to filter the contents of any given view:

    private ListViewWebPart GetListViewWebPart()
    {
        ListViewWebPart webPart = new ListViewWebPart();

        foreach (WebPart wp in WebPartManager.WebParts)
        {
            if (wp.GetType() == typeof(ListViewWebPart))
            {
                webPart = (ListViewWebPart)wp;
            }
        }
        return webPart;
    }


    private void ApplyStrategySecurity(string camlFilter)
    {
        // Get the listview webpart
        ListViewWebPart wp = GetListViewWebPart();

        // Apply the query to the listview
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(wp.ListViewXml);
        if (camlFilter.Length > 0)
        {
            XmlNode queryNode = doc.SelectSingleNode("//Query");
            XmlNode whereNode = queryNode.SelectSingleNode("Where");
            if (whereNode != null)
                queryNode.RemoveChild(whereNode);
            XmlNode newNode = doc.CreateNode(XmlNodeType.Element, "Where", string.Empty);
            newNode.InnerXml = camlFilter;
            queryNode.AppendChild(newNode);
        }
        wp.ListViewXml = doc.OuterXml;
    }
Dylan Berry
A: 

Dylan, thanks for the sample code.. It works ok for a Standard list but when I try to use it on my Gantt List it doesn't seem to do anything. Any ideas?

Vinny