i have a zone in a webpart page which has around 4 webparts in it. I want to create a accordion wp which when add to the webpart page, show the 4 webparts inside the accordion tabs.
EDIT The number of webparts inside the zone will increase.
|
i have a zone in a webpart page which has around 4 webparts in it. I want to create a accordion wp which when add to the webpart page, show the 4 webparts inside the accordion tabs. EDIT The number of webparts inside the zone will increase. |
||||
|
|
|
Twitter Bootstrap has a nice accordion solution they call Collapse. You don't need to include much to make it work with SharePoint. I use the tabs myself without any issues. For the selecting you can use jQuery to traverse through parents (.closest()), but another option is to make your own Web Part and use WebPart.WebPartManager to print all the web part IDs, then you can simply select by
And with jQuery and underscore you do:
Update: In your code behind you could fetch the Web Parts like this:
and enforce that Title is visible, the JavaScript might need it for collapse headings:
|
||||
|
What you could do is use the jQuery Accordion http://docs.jquery.com/UI/Accordion Just put every webpart within a div and beneath a h3. And surround them all with a div. Like this example:
Then you only have to add the following script, and it should work (+inlcude jQuery of course...):
|
|||
|
|
|
If the other web parts are just there for rich content, one possible approach is to create a list with a field set to Rich Content, then use a customized ContentQueryWebPart to render the list contents and the html framework needed for the accordion. From there, you can tie in jQuery as normal. |
|||
|
|
|
Don't think you'll be able to create a web part in which you can nest other web parts. Your best best would be to create a new Web Part Page layout that contains accordion tabs, each containing a web part zone and then add each of you web parts to an instance of that page. |
|||||
|