开发者

SharePoint Content Query Web Part - Ignoring Current Level

Consider this SharePoint site hierarchy:

开发者_开发技巧
- Site Collection
 - Site1
     - Subsite1
         - AnotherSubsite1
             - Page1
             - Page2
         - AnotherSubsite2
     - Subsite2
         - Page3
         - Page4
 - Site2

You can assume that every Site in the above hierarchy has a default page.

If I place a CQWP on Site1's default page, can I instruct it to start getting data one level below where it was placed? i.e. ignore the page/site it's currently on, so that it returns:

     - Subsite1
         - AnotherSubsite1
             - Page1
             - Page2
         - AnotherSubsite2
     - Subsite2
         - Page3
         - Page4

Thank you


I would extend the CQWP and then hook up my own ProcessDataDelegate to remove the data that's not required. For example:

protected override void OnInit(EventArgs e)
{
    this.ProcessDataDelegate += ProcessItems;
}

public DataTable ProcessItems(DataTable data)
{
    // Query the DataTable and remove unnecessary information
}

The WebId column in data is the GUID for the SPWeb object of each returned item. Look up SPWeb.ID of the sites you no longer want and then remove these rows. Note that the GUIDs in the WebId column are upper-case and in "D" format as described in Guid.ToString().

Remember to use AcceptChanges() at the end to ensure the DataTable is updated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜