autocomplete with sql using subgridparams

Questionsautocomplete with sql using subgridparams
Adrian asked 4 years ago

Hi,

I wondering if it is possible to use in sql statement something like this (or how to do this):

in first grid:

$grid[“detail_grid_id”] = “list2”;
$grid[“subgridparams”] = “comanda”;

in second grid:

$comanda = $_GET[“comanda”];

….

$col = array();
$col[“title”] = “Denumire piesa”;
$col[“name”] = “denumire_piesa”;
$col[“width”] = “150”;
$col[“formatter”] = “autocomplete”;
$col[“formatoptions”] = array(“sql”=>”SELECT DISTINCT denumire_piesa as k, denumire_piesa as v FROM piese_tot_comanda_croi where comanda=$comanda“);
$col[“export”] = true;
$col[“editable”] = true;
$col[“editoptions”] = array(“autocomplete”=>”off”,”list”=>”autocompleteOff”);
$col[“editrules”][“required”] = true;
$col[“formatoptions”][“op”] = “bw”;
$cols_d[] = $col;

In this way I get : 500 : Internal Server Error. Status: error

in browser debugger: Couldn’t execute query. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘AND denumire_piesa like ‘d%” at line 1 – SELECT DISTINCT denumire_piesa as k, denumire_piesa as v FROM piese_tot_comanda_croi where comanda= AND denumire_piesa like ‘d%’

I appreciate any help!

1 Answers
Abu Ghufran Staff answered 4 years ago

Hi,

When the subgrid initially loads, there is no value passed in $_GET so that case is not handled here.
You can replace $_GET data fetch with following.

$comanda = !isset($_GET[“comanda”]) ? 0 : $_GET[“comanda”];

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

16 + 0 =

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?