Friday, February 7, 2014

Cascading dropdowns in newform.aspx

I decided to go ahead and do something that is pretty standard in most web forms.
That is to make dropdowns scope the number of options in the select clause.  This
is fairly straightforward in a custom web app.  When we want to do it inside the
Sharepoint model it is a bit more challenging.

First, thing I tried was to edit the newform.aspx in Sharepoint 2010.  I noticed
that the webpart where the item adding happens is not configurable. It just displays a
sample of what you'll get rendered in the page.

The reason for this is the default webpart used here is from the type ListFormWebPart, whose behavior is to automatically render the fields and controls needed according to the list definition. No customization here.
First step I needed to do was add a CEWP to the newform.aspx.  Modifying the form is challenge

1.)Add the CEWP using the UI.  Doing it in Designer 2010 is a real challenge.
Open a browser and navigate to the location of the list.  Append the name/value
 pairing (toolpaneview=2#)
 http://<yourserver>/Lists/MyCustomList/newform.aspx?toolpaneview=2

Source:
http://sharepoint.stackexchange.com/questions/20395/how-to-add-a-webpart-using-sharepoint-designer-2010

2.) Site Actions > Edit Page

newform.aspx?PageView=Shared&InitialTabId=Ribbon.WebPartPage&VisibilityContext=WSSWebPartPage#

3.) Add Web Part > Categories | Media and Content |  Content Editor

4.) Your web part will say “ Edit this web part to add content to your page”  Click on Content Editor Menu and go to Edit Web Part

5.) Now you can click on HTML under Format Text and click on Edit HTML Source

6.) In HTML Source Editor you can input your HTML source.  This is how you edit Content Editor Web Part to add html source in SharePoint 2010

7.) Force page reload to get the page to update

Source:
http://aryannava.com/2011/05/14/how-to-edit-source-in-content-editor-web-part-in-sharepoint-2010/

8.) Next I followed this example to create a working cascading dropdown.

http://www.sharepointboris.net/js/spcd/

http://blogs.interfacett.com/sharepoint-designer-2010-creating-a-custom-list-form-with-sharepoint-2010

No comments:

Post a Comment