CHANGE DYNAMICALLY THE SOURCE OF GRID2-DROPDOWN LIST BASED ON GRID1.COLUMN1

QuestionsCHANGE DYNAMICALLY THE SOURCE OF GRID2-DROPDOWN LIST BASED ON GRID1.COLUMN1
Pierre Aaron Mata Trejo asked 3 years ago

Hello, looking to have the following.

In grid1 i have next settings:

$opt[“detail_grid_id”] = “list2”;
$opt[“subgridparams”] = “id,idserie”;

in grid2 have a column with:

$col = array();
$col[“title”] = “SubSerie”;
$col[“name”] = “idsubs”;
$col[“formatter”] = “select”;
$str2 = $grid2->get_dropdown_values(“select id as k, concat(clave,concat(‘-‘,descrip)) as v from subseries where client_id=”.$IDSERIE);
$col[“edittype”]=”select”; $col[“editoptions”] = array(“value” => $str2, “separator” => “:”, “delimiter” => “;”);
$cols2[] = $col;

obviously the use of $IDSERIE in the source of the dropdown list doesn’t work….

The idea is with “$IDSERIE” will can change dynamically the source of dropdown list based in a field of the grid1, Any ideas on how to do this?

2 Answers
Abu Ghufran Staff answered 3 years ago

Hi,

I could have explain better if I can see full code. However,
Most likely you will be using parent grid parameters in detail grid select. If you can select the idserie in select query, It can solve the issue.

$IDSERIE = $_GET["idserie"];
$grid2->select_command = "SELECT ...,idserie,... FROM tab WHERE condition";

Now when you have idserie available in select, you can create a column (hidden,non-editable,non-export) and just use it in onload-sql query with placeholder {idserie}

// removed where condition from this query. It will have all set.

$str2 = $grid2->get_dropdown_values("select id as k, concat(clave,concat('-',descrip)) as v from subseries");
$col["edittype"]="select"; $col["editoptions"] = array("value" => $str2, "separator" => ":", "delimiter" => ";");

// when editing, it will reload again with this query using placeholder.

$col["editoptions"]["onload"]["sql"] = "select id as k, concat(clave,concat('-',descrip)) as v from subseries where client_id = {idserie}";

 

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
PIERRE AARON answered 3 years ago

Perfect. works fine…. thanks a lot !!!

Your Answer

3 + 10 =

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?