SPCascadeDropdowns on EditForm.aspx

Sep 14, 2010 at 5:25 PM
Edited Sep 14, 2010 at 5:35 PM

Marc

I have a Region - Country cascade dropdown on the NewForm and EditForm pages in a custom list.

On the NewForm, I am able to select a region which updated the countries dropdown.

Here is the jQuery which is on both the pages.

<script languague="javascript" type="text/javascript">

    $(document).ready(function()
    {
  $().SPServices.SPCascadeDropdowns({
            relationshipList: "RegionCountry",
            relationshipListParentColumn: "Region",
            relationshipListChildColumn: "Country",
            parentColumn: "Region",
            childColumn: "Country"
        }); 
       
    });
</script>

When I save the item, and go to the EditForm.aspx for the item, for the saved region, it is defaulting to the 1st item in the countries dropdown for that region.

Any ideas how on the EditForm, we can prevent the child dropdown going back to the 1st item?

Any help would be appreciated.

Thanks

-Pritam

Coordinator
Sep 15, 2010 at 12:47 AM

Pritam:

I'm not sure I understand "When I save the item, and go to the EditForm.aspx for the item, for the saved region, it is defaulting to the 1st item in the countries dropdown for that region." Is it the Country or the Region which is the issue? Also, do you have the parent/child relationship backward? i.e., which is the major (parent) vs. minor (child) grouping?

M.

Sep 15, 2010 at 12:42 PM
Hi Marc
The Region is the parent dropdown and the Country is the child dropdown.
There are no issues with he cascade replationship.
The issue is with the child dropdown on the EditForm.
e.g.
Region List:
==========
North America
EMEA
LatAm

Country List:
==========
USA
UK
France
Spain
Mexico
Argentina

RegionCountry List:
===============
North America        USA
EMEA                   UK
EMEA                    France
EMEA                    Spain
LatAm                    Argentina
LatAm                    Mexico

Now, in the New Form, if I pick Region => LatAm, the country dropdown has two values: 1st one is Argentina and 2nd is Mexico, which is correct.
I now select Mexico as the Country and save the list item.

Now, when I go to the EditForm,aspx page for the item, the region shows up correctly as "LatAM", however, the country resets to the 1st item for that region which is "Argentina".

The same thing happens if I pick EMEA as the region...on the editform,aspx page, the country resets to the 1st item which is "France"
I do not have any other code on the page or any other columns than the 2 dropdowns and the default title column.

I guess, on the editform.aspx page the change event handler is firing for the region select box which is resetting the value??

Any help would be appreciated.

Thanks

-Pritam

On Tue, Sep 14, 2010 at 8:47 PM, sympmarc <notifications@codeplex.com> wrote:

From: sympmarc

Pritam:

I'm not sure I understand "When I save the item, and go to the EditForm.aspx for the item, for the saved region, it is defaulting to the 1st item in the countries dropdown for that region." Is it the Country or the Region which is the issue? Also, do you have the parent/child relationship backward? i.e., which is the major (parent) vs. minor (child) grouping?

M.

Read the full discussion online.

To add a post to this discussion, reply to this email (SPServices@discussions.codeplex.com)

To start a new discussion for this project, email SPServices@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com




--
Pritam Dahake
PRD Solutions Inc.
732-322-0185
Coordinator
Sep 15, 2010 at 1:36 PM
Your RegionCountry list is unessessary and is probably what is causing the problem. If your Country column is a lookup to the Country list, then the relationships should be there as well. The way you've got it set up, the selected ID won't match. Look at the example in the docs again to see what I mean. M.
Aug 15, 2011 at 10:47 AM
Edited Aug 16, 2011 at 10:12 AM

Hi Pritam

Did you find any solution to this?

Coordinator
Aug 15, 2011 at 12:19 PM
Bambino:

I think Pritam's problem was the relationships list setup.

Are you having similar problems? If so, why not start a new thread, and we'll sort it out.

M.
>
Aug 16, 2011 at 10:11 AM

Ok, have created an issue here: http://spservices.codeplex.com/workitem/9072

Aug 22, 2011 at 1:55 PM

Marc,

I believe I have the same issue as the original poster.

I have three dropdowns Service, Queue and Assigned.

When I create a new list item all the cascades work fine and match to the correct lookups.

If I display the newly created list item all is correct. However when I edit the list item "Service" remains as it was previously set but the "Queue" and "Assigned" dropdowns revert to "Choose Queue", "Choose Assigned". The cascades are still working correctly and I can set the values again but the original saved values have been reset on the form. If I cancel the edit and display the item again the information is as it was originally saved.

I am using the latest recommended versions of JQuery and SPServices.

Any help would be much appreciated.

Thanks

Coordinator
Aug 22, 2011 at 8:53 PM
Edited Aug 22, 2011 at 9:33 PM

Hmm. Not usre, ktspar.

Have you checked to be sure that the correct values are stored in the item before going to the EditForm? Have you done any other customizations on the EditForm? Where are you putting your script in the page?

M.

Aug 22, 2011 at 9:25 PM

Marc,

We are having the same problem that ktspar described with both the SPCascadeDropdown function and the SPFilterDropdown function.  We are putting the script in a CEWP because we don't have access to the file system page and can't use SPD to customize the page.  We only have 1 CEWP on the EditForm.aspx page with the SPServices functions.

Thanks for these great functions and help getting them implemented.

Coordinator
Aug 22, 2011 at 9:34 PM
Edited Aug 22, 2011 at 9:34 PM

Can you show the script you are using, and describe the lists?

M.

Aug 23, 2011 at 7:20 AM
Hi Marc,
This is my code. I am posting here as I have the same issue as the original poster.
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

<!--[OKSS]: 210611 adding support for cascading dropdowns -->
<script language="javascript" type="text/javascript" src="http://intranet/sites/avviksbehandling/JS/jquery-1.6.2.min.js" ></script>
<script language="javascript" type="text/javascript" src="http://intranet/sites/avviksbehandling/JS/jquery.SPServices-0.6.2.min.js" ></script>

<script language="javascript" type="text/javascript">
	$(document).ready(function()
	{
		//The list Avvik contains the mapping between Avvikskategori and avvik
		$().SPServices.SPCascadeDropdowns(
		{
			relationshipList: "Avvik",
			relationshipListParentColumn: "Hovedavvik",
			relationshipListChildColumn: "Title",
			parentColumn: "Avvikskategori",
			childColumn: "Avvik",
			simpleChild: true,
			debug: false 
		
		});
		
		//The list Lokasjon contains the mapping between Region and Enhet
		$().SPServices.SPCascadeDropdowns(
		{
			relationshipList: "Lokasjon",
			relationshipListParentColumn: "Region",
			relationshipListChildColumn: "Title",
			parentColumn: "Region",
			childColumn: "Enhet",
			simpleChild: true,
			debug: false 
		
		});
		
		
		$().SPServices.SPCascadeDropdowns(
		{
			relationshipList: "Tiltak",
			relationshipListParentColumn: "Tiltakstype",
			relationshipListChildColumn: "Title",
			parentColumn: "Tiltakstype",
			childColumn: "Tiltak",
			simpleChild: true,
			debug: false 
		
		});

	
		
		//Making the duedate field readonly
		$("input[Title='Behandling forfallsdato']").prop("disabled","disabled");
		
		//Hide the delete button
		$(”td.ms-titlearea”).hide();
		$(”a[title='Delete Item']“).parent().parent().parent().hide();
		$(”td.ms-separator:nth-child(4)”).hide();


	});


</script>
<!--[OKSS]: End modification -->
Aug 23, 2011 at 10:15 AM

Marc,

Thanks for your help on this, below is a description of my lists and the code from the edit form.

As I mentioned before all the cascades populate correctly but when you reopen the edit form the queue and assigned form fields get reset to "Choose" and don't hold on to the originally saved values.

The edit form was created in sharepoint designer and the only changes from the default is the insertion of Spservices code.

Service List

Columns

Service (Title)    Queue

Service 1              Q1

Service 2              Q2

Service 3              Q1

Service 4              Q3

MDQueue List

Columns             

Queue

Q1

Q2

Q3

MDPersonQ List

Columns

Title                     Queue

Person 1              Q1

Person 1              Q2

Person 2              Q1

Person 2              Q3

Person 3              Q3

</SharePoint:UIVersionedContent>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

<script language="javascript" type="text/javascript" src="../../JQuery/jquery-1.6.2.min.js"></script>
<script language="javascript" type="text/javascript" src="../../JQuery/jquery.SPServices-0.6.2.min.js"></script>
<script language="javascript" type="text/javascript">
 $(document).ready(function() {
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Service",
   relationshipListParentColumn: "Title",
   relationshipListChildColumn: "Queue",
   parentColumn: "Service",
   childColumn: "Queue",
   debug: true
  });
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "MDPersonQ",
   relationshipListParentColumn: "Queue",
   relationshipListChildColumn: "Title",
   parentColumn: "Queue",
   childColumn: "Assigned",
   });

  });
</script>


<SharePoint:UIVersionedContent UIVersion="4" runat="server">

 Thanks again.

Coordinator
Aug 26, 2011 at 7:08 PM
Edited Aug 26, 2011 at 7:08 PM

ktspar:

It looks to me like you have your parent/child relationship backward in the first call to SPCascadeDrodpowns vs. the second. The second looks correct to me. The bottom line is that I think your list structures don't quite jive with the way you are using them in your calls. This is a frequent problem, and always hard to explain. The docs are the best thing I can point you to.

M.

Sep 1, 2011 at 12:25 PM

Marc,

Thanks for your reply, I seemed to have resolved the issue by making the service and queue items required fields.

Now when I use the edit form it remembers the previous choices, I'm not sure if this is a "real" fix but it appears to be working for me in this context.

Much appreciated

ktspar

 

Sep 7, 2011 at 9:10 AM

Hi Marc,

I'm still having the same problem, even having applied the "solutions" described above.

By the way, I am using site columns and content type, rather than their own on the library. Oh, yes, I use a library, not a list  :)

 The Parent is a lookup field and the Child is a multiselect lookup field.

Anyway, I think the problem comes from the running of a SharePoint javascript, which runs almost simultaneously with the SPCascadeDropdowns script.

I say this because I noticed a javascript error in the browser saying that the fault is in the .js file /_layouts/groupeditempicker.js. However, function or parameter failure is "length is null or not an object", which if I remember correctly is in the SPCascadeDropdowns script.
From what I've seen, groupeditempicker.js checks which elements were selected in the field and places them as selected.

In addition, the EditForm actually does work. That is, load a document (UploadFormin my case, instead of NewForm for lists) and save directly without filling the fields we have filtered with jQuery. Then edit the document with the EditForm and... voilà!, the fields works perfectly, as in the NewForm. But then, if saved and re-edit, you get the error.

Therefore, the failure only occurs when we have selected a child element in the field and then editing.

 

Any idea?

Thanks in advance.


 

Sep 8, 2011 at 2:59 PM

Ok, solved using 1.5.2 jQuery version.

Don`t know why is failing with 1.6.2 version.

 

Thanks anyway!

Coordinator
Nov 6, 2011 at 4:13 AM

I believe that I have a fix for this issue in v0.6.3ALPHA9. I'd appreciate it if you could test it out if you can.
http://spservices.codeplex.com/releases/view/68781

M.

Nov 8, 2011 at 8:23 PM

Hello,

In my case SPCascadeDropdowns of SPServices 0.6.2 works well with jQuery 1.6.4 but not with jQuery 1.7.

I tried v0.6.3ALPHA9 with jQuery 1.7 but it doesn't work either.

Thank you.

 

Coordinator
Nov 8, 2011 at 8:26 PM

jQuery 1.7 is another thing altogether. See my blog post from today.

What I'm hoping to validate is that SPCascadeDropdowns in SPServices 0.6.3ALPHA9 works on EditForms with jQuery 1.6.x.

M.