SPCascadeDropdowns - Show all Childs if Parent not chosen

May 29, 2012 at 1:37 PM
Edited May 29, 2012 at 1:38 PM

Hey guys,

im trying to get my idea working, but i dont know how to do it right.

The idea was to show all Child Items if no parent item was chosen.

So im searching now for the ID of the parent dropdown list to get the value:

case "S":
                            var e = document.getElementById(ID);
                            var element = e.options[e.selectedIndex].text;
                            if (element == "") {
                                break;
                            } else {
                                // Remove all of the existing options
                                $(childSelect.Obj).find("option").remove();
                                // If the column is required or the promptText option is empty, don't add the prompt text
                                if (!childColumnRequired && (opt.promptText.length > 0)) {
                                    childSelect.Obj.append("<option value="0"></option>" + opt.promptText.replace(/\{0\}/g, opt.childColumn) + "");
                                } else if (!childColumnRequired) {
                                    childSelect.Obj.append("<option value="0"></option>" + opt.noneText + "");
                                }
                            }
                            break;
                        case "C":

 

 

Someone able to help me here?

Thank you!

Coordinator
May 30, 2012 at 4:30 AM

Marcel:

As you've surmised, SPCascadeDropdowns is written to only show the children of the currently selected parent. It looks like you are trying to change the function so that it displays all of the children if there is no parent selection. Just as there is a childSelect.Obj, there's a parentSelect.Obj used in the function.

That should help you get rolling.

M.

May 30, 2012 at 12:48 PM

Hey, thank you for your answer. But how do i manage it to get the selected value?

something like this doesnt work:

 

var eingegeben = parentSelect.Obj.selected.text;

thank you!

Coordinator
May 30, 2012 at 12:58 PM

Since your rummaging around in the SPServices code, you have everything you need to look at. The parentSelect.Obj will point at different things based on what type of column it is and how many items the dropdown is displaying.

M.

May 31, 2012 at 12:09 PM

Yeah i got it working right now, im using this code :

var input = getDropdownSelected(parentSelect);


if (input == "" || input =="(None)" && opt.ShowAllIfEmpty) 

[...]

 

 

 

For everyone who is searching for the same

Coordinator
May 31, 2012 at 1:41 PM

Great! Sorry I wasn't more help.

Could you send me the block of code that contains your change? (Just add some or the code around it so that I can see where you put this.) I think this might make a nice new option for the function.

Thanks,
M.

Jul 5, 2012 at 10:20 AM
marceleberling wrote:

Yeah i got it working right now, im using this code :

var input = getDropdownSelected(parentSelect);


if (input == "" || input =="(None)" && opt.ShowAllIfEmpty) 

[...]

 

 

 

For everyone who is searching for the same

 

Hi, I want also, to use this.

Can you explain where to use the code mentioned?

Thanks,

Ovidiu

Jul 13, 2012 at 1:45 PM

Still no answer on this issue?

Maybe Marc can help.

Thanks, Ovidiu

Coordinator
Jul 13, 2012 at 5:40 PM

What are you looking for?

M.

Jul 16, 2012 at 7:35 AM

Hi,

I want to get exactly what the post title said: Show all Childs if Parent not chosen.

I have a list with documents which have to be filtered by projects. But I have a lot of documents which don't have a project associated and I cannot see them.

I am newbie in JQuery and I saw that marceleberling resolve it in one way, but I don't know where to add the mentioned code.

Maybe you can help me with some guidance.

Thanks, Ovidiu

Coordinator
Jul 17, 2012 at 2:35 PM

Ovidiu:

SPCascadeDropdowns won't show any child values unless the parent has associated child values in the relationshipList. This is by design.

In yiour case, you probably will want to code some script to handle the "no project" case.

M.