SP2010 Modal Dialog for Content Type “New” Form
-
16-10-2019 - |
문제
When you create a new document set, you are presented with a modal dialog such as the following:
I want to have this kind of "New Form" (modal) for my custom content type (with custom form).
Now, I know that I can create my own modal dialogs using the Javascript API (e.g. http://www.chakkaradeep.com/post/Using-the-SharePoint-2010-Modal-Dialog.aspx). Also there is the NewFormUrl
property for a content type, where I can redirect the user upon creating a new item from my content type ( http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontenttype.newformurl.aspx) - this is not the same, because I think it is nicer to stay on the same page.
I still don't know how I would get Javascript to fire upon creating a new item from my content type, so I could call the modal dialog api. What I basically want is this:
New > MyContentType > User is presented with a form as in the Screenshot above > User enters some metadata > Item based on MyContentType is created with metadata entered by user.
Also when creating my own content type new form, would I need to recreate everything Microsoft has done so nicely for the Document Set (i.e. Save Button, Check-In, Copy/Paste)?
EDIT: And then there is that: How to Open a List Form in a Modal Dialog Box
해결책
You should not have to worry about how the dialog launches, it should happen seamlessly from the ribbon new button no matter the content type. I would check two things:
Is the site operating with v4 (sp2010) visual styles?
Is the list configured to show forms in a dialog.
List Settings -> Advanced -> Dialogs -> Launch forms in a dialog? -> Yes
The list forms, NewForm.aspx, DispForm.aspx, EditForm.aspx are all full pages with master page wrappers and everything. SharePoint 2010 magic happens when "Launch forms in a dialog?" is turned on, and only the content of the form is displayed in the dialog.
다른 팁
try this
New Item:
javascript:EditItem2(event,"/_layouts/listform.aspx?ListId={YOUR_LIST_ID} &RootFolder=YOUR_ROOT_FOLDER &ContentTypeId=ITEM_CONTENTTYPE_ID");
but check this out http://tuan-tomy.blogspot.com/2010/09/redirect-to-link-to-new-item-with.html