parent with multiple children

Feb 11, 2010 at 11:39 AM
Edited Feb 11, 2010 at 11:40 AM

Hello there,

nice work, done with this solution.        

At least there is a thing which does not work properly and needs some changes and additions to the code.
I figured out a case in which a cddl (i will use this for 'cascading drop down list') has more than one child.

I wanted to connect spoken languages and existing cities to a country a user chooses.
e.g.: german is spoken in germany, Berlin is a city in germany
e.g.: english is spoken in the USA, New York is a city in the USA

To cover this case I wasn't able to work out a solution just using the solution you offer here to download.
The base cddl only allows to connect one parent with one children in one list.

To add the possibility to declare more than one child i touched the source code and added a few lines of code.
Perhabs it is not possible to change the already built solution but you can easily built a new solution with the source code.

To those of you who want the cddl to allow more than one child just alter the "DropDownList_SelectedIndexChanged" method in CascadingDropDownListFieldWithFilter.cs (CascadingDropDownListFieldControlWithFilter class)

void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
    EnsureChildControls();
    try
    {
	if (cddlChildName.Length > 0)
	{
	// added split to child names to use a parent for multiple children controls
	    if (cddlChildName.Contains(";"))
	    {
		string[] childrenNames = cddlChildName.Split(new string[] { ";", " " }, StringSplitOptions.RemoveEmptyEntries);
		
		foreach (string childName in childrenNames)
		{
		    CascadingDropDownListFieldControlWithFilter child = (CascadingDropDownListFieldControlWithFilter)FindControlRecursive(this.Page, childName).Parent.Parent;
		    if (child != null)
                      {
			DropDownList ddl = (DropDownList)FindControlRecursive(this.Page, child.cddlParentName);
			Debug.Write(ddl.SelectedValue);
			PopulateChild(child, ddl.SelectedValue);
		    }
		}
	    }
	    else
	    { // run the normal case if childName is only one controlname (old code)
		CascadingDropDownListFieldControlWithFilter child = (CascadingDropDownListFieldControlWithFilter)FindControlRecursive(this.Page, cddlChildName).Parent.Parent;
		if (child != null)
		{
		    DropDownList ddl = (DropDownList)FindControlRecursive(this.Page, child.cddlParentName);
		    Debug.Write(ddl.SelectedValue);
		    PopulateChild(child, ddl.SelectedValue);
		}
	    }
	}
    }
    catch
    { }
}
After making this change just built the wsp solution and deploy it to your SharePoint.
Activate the feature "Stoneshare Cascading DropDown Field (With Filter)" and create your cascading drop down list fields.
This solution enables you to declare one or more children and seperate them with "; " (you can change the code to whatever you want to seperate the names)
I hope this works for those of you looking for the option to create a parent with multiple children
Best regards
Yggdrasil





Aug 31, 2010 at 10:24 PM

Hi Yggdrasil,

I am interested in your solution. I need to have parent and multiple children relationship. I am not a programmer. Can you please share your wsp file with me? Is there a way I can download and deploy to my server farm? I appreciate your help. You can send me wsp file to my email address - shahfa@hotmail.com

Thanks,
Falgun

Feb 22, 2011 at 3:41 PM

Hi,

If you consider a paid solution, our product supports both multiple parents and multiple children scenarios.

Up to 2 ( or 3, i dont remember :) ) parents filtering the same column, and unlimited children (as long as you dont mind the AJAX updates on the client side).

http://www.kwizcom.com/sharepoint-add-ons/sharepoint-cascading-lookup-plus/overview/

Give it a go for 30 days, we can help with converting your existing data into this column.

Mar 10, 2011 at 8:58 AM

Hi Yggdrasil,

I am interested in your solution. I need to have parent and multiple children relationship. I am not a programmer. Can you please share your wsp file with me? Is there a way I can download and deploy to my server farm? I appreciate your help. You can send me wsp file to my email address - zeytoon77@yahoo.com

Thanks,
Zeytoon

Coordinator
Apr 17, 2013 at 3:54 AM
Hi Everyone,

My apologies for my extended absence. I've been completely out-of-sync with this project working on other things, and it will take me some time to come up to speed with all the discussions happening on this project.

I realize this is outdated code and would need to be made compatible with the latest version of SharePoint. If anyone has tested code that is available, please connect with me and I can have the code uploaded as part of this project.


Thanks,
Sarith