| Support Center

(Back to Website)

Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Multiselect in form with dependent dropdowns

JPhilip Feb 02, 2018 02:29AM PKT

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!

Up 0 rated Down
Abu Ghufran Feb 12, 2018 11:18PM PKT PHP Grid - Support Center Engineer
You can refer this code demo:
https://gist.github.com/gridphp/566a78f26cbb0f599d1768af9425d41b

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

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Contact Us

  • Post a Public Question
  • Email Us
  • Live Chat!
  • Ask the Community

    Instructions

    • Paste complete code that is involved in your question. You can use pastebin.com to share code link.

    Screenshots or Online link of webpage is helpful in resolution. You can also send email at address mentioned below.

    • To report an issue, Write steps to regenerate the case.

    • For email support or live chat, Use gridphp@gmail.com and add it in Google Chat.
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete