Hi to all,
based on the following link:
https://suitecrm.com/forum/developer-help/828-dynamic-multiselect
i would like to impement something like that but with 2 multiselect fileds(the last one must depends on the first one).
I saw a lot of discussion on it and i donāt really understand if its achieveable or not.
Another possible solution could be to have 1 parent single dropdown list that drives the second multiselect (exactly like the link above).
The only difference could be the possibility to add multiple filed just like when you add condition or actions in the workflow.
To clarify:
parent dropdow -> products(laptops, workstations)
child multiselect -> types (laptops-a, laptops-b,workstations-a, workstations-b)
in editview i select from products ālaptopsā and in the type multiselect field i should select only ālaptops-a or laptops-b or bothā.
Then clicking on a ā+ā button i would add a new selection for products and types.
Anyone could point me on the right way?
Thank you
HI rainolf,
Best way to achieve this to use jquery, what i preferred.
Follow this,
First drop down,
<select id="1st">
<option value="">Select Type</option>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
Second drop down,
<select id="2nd">
<option value="">Select Type</option>
<option value="a_x">x</option>
<option value="a_y">y</option>
<option value="a_z">z</option>
<option value="b_p">p</option>
<option value="b_q">Q</option>
</select>
Jquery is here,
$('#1st').change(function(){
var e = this.value;
$("#2nd > option").show();
$("#2nd > option:not([value^=\""+e+"\"])").hide();
$("#2nd").val($('#2nd>option:visible:first').val());
});
your mission will be achievedā¦
Hi jaydeep,
thank you for your quick reply.
Let me ask you something more in order to have a clear understanding.
1 - the code you wrote are related to both multiselect fields?
2 - the jquery library inclusion are already present in SuiteCRM code or must be downloded and included(in that case where mut be placed)?
3 - this is my first experience in coding around SuiteCRM so could you point me where must i have to place the code above?
4 - the code code abive must be hardcoded or i need first to create fields in studio?
5 - is this customization upgrade safe?
Thank you very much for all
Regards
1 - the code you wrote are related to both multiselect fields?
Yes it is. But you need to use for each loop for multipule select.
2 - the jquery library inclusion are already present in SuiteCRM code or must be downloded and included(in that case where mut be placed)?
Jquery libraray is already present.No need to download anything.
3 - this is my first experience in coding around SuiteCRM so could you point me where must i have to place the code above?
include the .js file in these two following files only.
You need to use customcode in editviewdefs.php (if u want in edit page).
You need to use customcode in searchviewdefs.php (if u want in search page).
4 - the code code abive must be hardcoded or i need first to create fields in studio?
You need to hardcode it. studio wonāt work here.
5 - is this customization upgrade safe?
Indeed it is upgradesafe
Hi jaydeep,
thank you for your help.
I will try the code and let you know.
Hope ti disturb you again for any further doubts.
Thans again
Hi jaydeep,
my apologies.
Starting to develop iāve realized that i need to understand better how SuiteCRM works.
My questions are:
Can u point me on a developer guide useful to start with it?
Just to understand the logic behind:
- the dropdown code must be wrote in the same js or where?
- have i to first create fields in studio or not?
- could you provide me a valid example?
Thank you
Just to descibe you better iāve made a test.
Iāve created one field in studio with js inclusion and the result in ediviewdefs is:
āLBL_PANEL_ADVANCEDā =>
array (
0 =>
array (
0 => āstatusā,
1 => ālead_sourceā,
),
1 =>
array (
0 =>
array (
ānameā => āstatus_descriptionā,
),
1 =>
array (
ānameā => ālead_source_descriptionā,
),
),
2 =>
array (
0 => āopportunity_amountā,
1 => ārefered_byā,
),
3 =>
array (
0 => ācampaign_nameā,
),
4 =>
array (
0 =>
array (
ānameā => ādbg_custom_service_type_cā,
āstudioā => āvisibleā,
ālabelā => āLBL_DBG_CUSTOM_SERVICE_TYPEā,
),
),
),
āincludesā =>
array (
0 =>
array (
āfileā => ācustom/modules/Leads/dbg_custom_leads.jsā,
),
),
Then iāve created for test dbg_custom_leads.js like this:
//Alert on Change:
$(function() {
$('#dbg_custom_service_type_c').on('change', function() {
alert("Changed!!!");
});
});
When i try to select one item in the field nothing happens, firebug also doesnāt show me any action triggered.
Thank you
Anyone can help me?
Maybe i need to include ta before?
Thank you
Hi rainolf,
Any JS error displayed ?
OR
Try following.
$(document).ready(function(){
$(ā#dbg_custom_service_type_cā).change(function(){
alert(āEvent Firedā);
});
});
Quick Repair and Rebuildā¦
Hope this helpsā¦