Cascading Multiple Selects

Hi All,

Were using rt 3.8.10 and I was wondering if anyone had managed to get cascading multiple selects working? What we have are two select boxes that both allow multiple selections, and we want one to cascade all selected categories to the other. At the moment only the first selected option in the first combobox is cascaded to the second combobox, even though multiple options are selected in the first combo box…

Maybe a picture will explain this better. In the example below I have selected just the first item in Agent Source (External), and it correctly cascades the two example options (External 1 and 2):

Same with if I select the second item in Agent Source (Internal) it correctly cascades the two Internal options to the Agent Type:

The problem arises when I need both categories cascaded to the Agent Type. Only the first category is populated:

Has anyone else struck this? Any ideas on how to fix it? Ive trolled the rt-users archives and cant find anyone else who has the issue. Any pointers would be appreciated.

Cheers

http://emailsignature/form/Telecom_spark.jpg

Terry MacDonald

Senior Systems Support Specialist - Security

T

+64 9 302 7816 (extn 99816)

M

+64 27 207 0688

F

+64 9 379 4790

E

terry.macdonald@telecom.co.nz

Level 9, Mayoral Dr Bldg, 31 Airedale Street
Auckland
Twitter: @telecomnz http://twitter.com/@telecomnz
www.telecom.co.nz http://www.telecom.co.nz/

This communication, including any attachments, is confidential. If you are not the intended recipient, you should not read it - please contact me immediately, destroy it, and do not copy or use any part of this communication or disclose anything about it. Thank you. Please note that this communication does not designate an information system for the purposes of the Electronic Transactions Act 2002.

PGP.sig (820 Bytes)

Yay! Fixed it myself.

I had to change the following files so that the full select ID of the master select gets passed to the filter_cascade function rather than just the first selected element. It means we can then loop through all of the selected options, and fully populate the cascaded select. Im sure the logic in filter_cascade could be more succinct but it works for me J

  • In File share/html/Elements/EditCustomFieldSelect
  • In File share/html/NoAuth/js/cascaded.js replace the whole filter_cascade function with:

function filter_cascade (id, masterid) {

var select = document.getElementById(id);

var complete_select = document.getElementById(id + "-Complete" );

var master_select = document.getElementById(masterid);



if (!select) { return };

var i;

var m;

var children = select.childNodes;



if ( complete_select ) {

    while (select.hasChildNodes()){

        select.removeChild(select.firstChild);

    }



    var complete_children = complete_select.childNodes;

            var master_children = master_select.children;

            var have_no_value_option = false;



            for (m in master_children) {

                    // we only want to continue if the option is selected

                    if (!master_select.options[m].selected) {

                            continue;

                    }



                    var val = master_select.options[m].value;



                    if ( val == '' && arguments.length == 3 ) {

                            // no category, and the category is from a hierchical cf;

                            // leave this set of options empty

                    } else if ( val == '' ) {

                            // no category, let's clone all node

                            for (i in complete_children) {

                                    if ( complete_children[i].cloneNode ) {

                                            new_option = complete_children[i].cloneNode(true);

                                            select.appendChild(new_option);

                                    }

                            }

                    }

                    else {

                            for (i in complete_children) {

                                    if (!complete_children[i].label ||

                                            complete_children[i].label.substr(0, val.length) == val ) {

                                            if (complete_children[i].label == '') {

                                                    if (!have_no_value_option) {

                                                            have_no_value_option = true;

                                                    } else {

                                                            continue;

                                                    }

                                            }

                                            if ( complete_children[i].cloneNode ) {

                                                    new_option = complete_children[i].cloneNode(true);

                                                    select.appendChild(new_option);

                                            }

                                    }

                            }

                    }

            }

}

else {

// for back compatibility

    for (i in children) {

        if (!children[i].label) { continue };

        if ( val == '' && arguments.length == 3 ) {

            hide(children[i]);

            continue;

        }

        if ( val == '' || children[i].label.substr(0, val.length) == val) {

            show(children[i]);

            continue;

        }

        hide(children[i]);

    }

}

}

Hope this works for you. It did for me on RT 3.8.10 J

Cheers

http://emailsignature/form/Telecom_spark.jpg

Terry MacDonald

Senior Systems Support Specialist - Security

T

+64 9 302 7816 (extn 99816)

M

+64 27 207 0688

F

+64 9 379 4790

E

terry.macdonald@telecom.co.nz

Level 9, Mayoral Dr Bldg, 31 Airedale Street
Auckland
Twitter: @telecomnz http://twitter.com/@telecomnz
www.telecom.co.nz http://www.telecom.co.nz/

This communication, including any attachments, is confidential. If you are not the intended recipient, you should not read it - please contact me immediately, destroy it, and do not copy or use any part of this communication or disclose anything about it. Thank you. Please note that this communication does not designate an information system for the purposes of the Electronic Transactions Act 2002.From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Terry MacDonald
Sent: Friday, 3 June 2011 6:31 p.m.
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Cascading Multiple Selects

  • PGP Signed: 3/06/2011 at 6:30:58 p.m.

Hi All,

Were using rt 3.8.10 and I was wondering if anyone had managed to get cascading multiple selects working? What we have are two select boxes that both allow multiple selections, and we want one to cascade all selected categories to the other. At the moment only the first selected option in the first combobox is cascaded to the second combobox, even though multiple options are selected in the first combo box…

Maybe a picture will explain this better. In the example below I have selected just the first item in Agent Source (External), and it correctly cascades the two example options (External 1 and 2):

Same with if I select the second item in Agent Source (Internal) it correctly cascades the two Internal options to the Agent Type:

The problem arises when I need both categories cascaded to the Agent Type. Only the first category is populated:

Has anyone else struck this? Any ideas on how to fix it? Ive trolled the rt-users archives and cant find anyone else who has the issue. Any pointers would be appreciated.

Cheers

http://emailsignature/form/Telecom_spark.jpg

Terry MacDonald

Senior Systems Support Specialist - Security

T

+64 9 302 7816 (extn 99816)

M

+64 27 207 0688

F

+64 9 379 4790

E

terry.macdonald@telecom.co.nz

Level 9, Mayoral Dr Bldg, 31 Airedale Street
Auckland
Twitter: @telecomnz http://twitter.com/@telecomnz
www.telecom.co.nz http://www.telecom.co.nz/

This communication, including any attachments, is confidential. If you are not the intended recipient, you should not read it - please contact me immediately, destroy it, and do not copy or use any part of this communication or disclose anything about it. Thank you. Please note that this communication does not designate an information system for the purposes of the Electronic Transactions Act 2002.

PGP.sig (820 Bytes)

Yay! Fixed it myself.

I had to change the following files so that the full select ID of the master select gets
passed to the filter_cascade function rather than just the first selected element. It means we
can then loop through all of the selected options, and fully populate the cascaded select. I’m
sure the logic in filter_cascade could be more succinct but it works for me J

Can you generate a patch for this and add it to the existing ticket on
this topic?

http://issues.bestpractical.com/Ticket/Display.html?id=16336&user=guest&pass=guest

-kevin