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!
You can refer this code demo:
https://gist.github.com/gridphp/566a78f26cbb0f599d1768af9425d41b
Place it in demos/appearance and test via demo app.