Multiselect in form with dependent dropdowns

QuestionsMultiselect in form with dependent dropdowns
JPhilip asked 6 years ago

Hi,

Has anyone been able to have a multiselect field that updates a dependent field? Currently the dependent field only shows values from the first selected value in the master field.

Below are the columns with the multiselect (Master) and the dependent field (Dependent).

// COLUMN: Master
$col = array();
$col['name'] = 'master';
$col['title'] = 'Master';
$col['export'] = true;
$col['hidden'] = false;
$col['editable'] = true;
$col['edittype'] = "select";
$str = $grid->get_dropdown_values("select master_id as k, master as v from v_get_master where field_type = 'master' and active = 1");
$col['editoptions'] = array("value"=>$str);
$col['editoptions']['multiple'] = true;
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col['name']}'); },200); }";
$col["editoptions"]["onload"]["sql"] = "select master_id as k, master as v from v_get_master where field_type = 'master' and active = 1";
$col["editoptions"]["onchange"]["sql"] = "select dependent_id as k, concat(master, ' – ', dependent) as v from v_get_dependent where master_id IN ({master})";
$col["editoptions"]["onchange"]["update_field"] = "dependent";
$col['editrules']['required'] = true;
$cols[] = $col;

// COLUMN: Dependent
$col = array();
$col['name'] = 'dependent';
$col['title'] = 'Dependent';
$col['export'] = true;
$col['hidden'] = false;
$col['align'] = 'center';
$col['editable'] = true;
$col['edittype'] = "select";
$str = $grid->get_dropdown_values("select dependent_id as k, concat(master, ' – ', dependent) as v from v_get_dependent where master_id IN ({master})");
$col['editoptions'] = array("value"=>":;".$str);
$col['editoptions']['multiple'] = true;
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col['name']}'); },200); }";
$col["editoptions"]["onload"]["sql"] = "select master_id as k, master as v from v_get_master where field_type = 'master' and active = 1";
$col['editrules']['required'] = true;
$cols[] = $col;

Any help would be greatly appreciated!

1 Answers
Abu Ghufran answered 6 years ago

You can refer this code demo:
https://gist.github.com/gridphp/566a78f26cbb0f599d1768af9425d41b

Place it in demos/appearance and test via demo app.

Your Answer

18 + 15 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?