How do I create a button on the ribbon and how do I move the selected item(s) from the list/library into a Document Set?
-
1Could you clarify your question, please? It seems like you're asking for a complete solution, rather than the answer to a specific query.– Stu PeggSep 22, 2011 at 21:08
-
@StuartPegg I did some editing to save this question. I provided an answer as well :)– Vedran RasolSep 22, 2011 at 21:29
-
@VedranRasol: :) Fair enough. However, it seemed like they were asking how they could enable a ribbon button when a list item is selected (in the first part of their question).– Stu PeggSep 22, 2011 at 21:36
-
@StuartPegg Thx, just to be on safe side I updated my answer to cover that option. I hope this question is now saved :)– Vedran RasolSep 22, 2011 at 21:45
1 Answer
Here you have something quite similar (just few changes needed):
How to Display a SharePoint Dialog from Ribbon Button and Get Selected Item Context
Basically you need two things:
- Custom ribbon/button similar to one described in article. With usage of dialog framework you open custom page and pass selected items values as querystring (all described in provided article)
- Custom Application page with one TextBox (DocumentSet name) and 2 buttons (OK, Cancel). OnLoad you read selected items from query string (article) and on button OK click you create your Document Set and move selected items into it (not in article!)
For that last part you can use info provided here: How to programmatically create document set, add or move files, GetDocumentSetById
For more info on Ribbon customizations I recommend reading SharePoint 2010 Ribbon Customization series by Chris O'Brien (@ChrisOBrienMVP).
Addition (thx goes to @StuartPegg):
Some info on how to enable Ribbon Button when item(s) in list is(are) selected:
Enable Ribbon button when one item only is selected and it is not folder
SharePoint 2010 Ribbon Customization Part VI: How to enable/disable buttons in ribbon conditionally?