[rt-users] Cascading Multiple Selects
Terry MacDonald
Terry.MacDonald at telecom.co.nz
Fri Jun 3 04:22:41 EDT 2011
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
<script type="text/javascript"><!--
doOnLoad( function () {
var basedon = document.getElementById('<% $NamePrefix . $CustomField->BasedOnObj->id %>-Values');
if (basedon != null) {
var oldchange = basedon.onchange;
basedon.onchange = function () {
filter_cascade(
'<% $id %>-Values',
'<% $NamePrefix . $CustomField->BasedOnObj->id %>-Values',
1
);
if (oldchange != null)
oldchange();
};
basedon.onchange();
}
});
--></script>
- 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 at 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 at lists.bestpractical.com [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Terry MacDonald
Sent: Friday, 3 June 2011 6:31 p.m.
To: rt-users at 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 at 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.
* Terry MacDonald <terry.macdonald at telecom.co.nz>
* 0x4E0BA852
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110603/0fe3f759/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 13662 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110603/0fe3f759/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 6540 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110603/0fe3f759/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 6188 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110603/0fe3f759/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 6460 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110603/0fe3f759/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 820 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110603/0fe3f759/attachment.sig>
More information about the rt-users
mailing list