Hi,
I need to change ( on edit form) sql of autocomplete according to a parameter.
My code:
$col = array();
$col[“title”] = “debitid”;
$col[“name”] = “debitid”;
$col[“width”] = “10”;
$col[“editable”] = true;
$col[“hidden”] = true;
$cols[] = $col;
$col = array();
$col[“title”] = “Dosar”;
$col[“name”] = “dosar_debit_more”;
//$col[“dbname”] = “dd.dosar_debit_more”;
$col[“width”] = “300”;
$col[“align”] = “left”;
$col[“formatter”] = “autocomplete”;
$col[“formatoptions”] = array(“sql”=>”SELECT id as k, dosar_debit_more as v FROM debite_dosare_view WHERE ABS(sold_ap_f)+ABS(sold_ac_f) > 0”, “search_on”=>”dosar_debit_more”, “update_field” => “debitid”, “force_select”=>true);
$col[“editable”] = true;
$col[“editrules”][“required”] = true;
$cols[] = $col;
and I want, on edit form, to force somehow a new sql forĀ autocomplete, somethink like:
“sql”=>”SELECT id as k, dosar_debit_more as v FROM debite_dosare_view WHERE ABS(sold_ap_f)+ABS(sold_ac_f) > 0 and buget=”.$(“#buget”).val()
Thank you in advance,
Adrian
Hi,
You can try this:
$col["formatoptions"] = array("sql"=>"SELECT id as k, dosar_debit_more as v FROM debite_dosare_view WHERE ABS(sold_ap_f)+ABS(sold_ac_f) > 0 AND buget={buget}", "search_on"=>"dosar_debit_more", "update_field" => "debitid", "force_select"=>true);
By this, it will replace {buget} with the value of column named ‘buget’, which is posted from clientside while sending autocomplete ajax request.
In case of further help, please share grid code and i’ll suggest the changes.