Master – Detail not passing the value (non PK)

QuestionsMaster – Detail not passing the value (non PK)
Don Mangold asked 10 years ago

When I pass a text value to the detail grid. I cannot get the value to display when I add a row. Below is my code – I have three grids. First is the master. Last this the grid I am trying to pass SPLOCATION in col INLOCATION so the user does not enter this information again. My final intention is the make this hidden anyway.

Any help would be great.

Code:
<?php

include("../../lib/inc/jqgrid_dist.php");
$g = new jqgrid($db_conf);

// set few params
$grid["caption"] = "StoneMor Partners – Cemetery Space Inventory";
$grid["detail_grid_id"] = "list3";
$grid["subgridparams"] = "SPID,SPOWNER,SPLOCATION";

$g->set_options($grid);
$g->set_actions(array("inlineadd"=>false));

// set database table for CRUD operations
$g->table = "CSISPACEP";

$wloc = "'".implode("','",$locations)."'";

// subqueries are also supported now (v1.2)
$g->select_command = "SELECT CSI.*,(select CONCAT(CONCAT(RTRIM(CUSTP.CUFNM),' '),TRIM(CUSTP.CULNM)) from CUSTP where CUSTP.CUCUST = CSI.SPOWNER) as OWNER,(select CONCAT(CONCAT(RTRIM(CSIINTERNP.INFIRST_NAME),' '),TRIM(CSIINTERNP.INLAST_NAME)) from CSIINTERNP where CSIINTERNP.INSPID = CSI.SPID) as INTERRED FROM CSISPACEP CSI where SPLOCATION in (".$wloc.")";

// If you want to customize columns params
$col = array();
$col["hidden"] = false;
$col["title"] = "SPID"; // caption of column
$col["name"] = "SPID";
$col["width"] = "10";
$cols[] = $col;

// If you want to customize columns params
$col = array();
$col["hidden"] = true;
$col["title"] = "SPOWNER"; // caption of column
$col["name"] = "SPOWNER";
$col["width"] = "5";
$cols[] = $col;

$col = array();
$spl = $g->get_dropdown_values("select distinct SPLOCATION as k, SPLOCATION as v from CSISPACEP where SPLOCATION in (".$wloc.")");
$col["stype"] = "select";
$col["searchoptions"] = array("skipEmpty"=>true, "value" => ":–All–;".$spl, "separator" => ":", "delimiter" => ";");
$col["title"] = "Location"; // caption of column
$col["name"] = "SPLOCATION";
$col["width"] = "20";
$col["sortable"] = true;

$g->set_columns($cols);

$g->set_actions(array(
"add"=>$roles['add'],
"edit"=>$roles['edit'],
"delete"=>$roles['delete'],
"view"=>$roles['view'],
"rowactions"=>false,
"export"=>$roles['export'],
"autofilter" => true,
"search" => false,
"inlineadd" => false,
"showhidecolumns" => false
)
);

/** Define Modify Owner Grid***/

$h = new jqgrid($db_conf);
….

/*** End of Modify Owner *****/

/** Define Internment Grid***/

$i = new jqgrid($db_conf);

// set few params
//$SPID = intval($_GET["SPID"]);

$SPID = (empty($_GET["SPID"])?0:$_GET["SPID"]);
$SPLOCATION = (empty($_GET["SPLOCATION"])?0:$_GET["SPLOCATION"]);

$e["on_insert"] = array("add_Intern", null, true);
$i->set_events($e);

// subqueries are also supported now (v1.2)
$i->select_command = "SELECT * FROM CSIINTERNP where INSPID = '".$SPID."'";

// If you want to customize columns params
$col = array();
$col["hidden"] = false;
$col["title"] = "LOCATION"; // caption of column
$col["name"] = "INLOCATION";
$col["width"] = "20";
$col["editoptions"] = array("size"=>20, "defaultValue"=>$SPLOCATION);

$col["sortable"] = false;
$col["editable"] = true;
$col["viewable"] = true;
$col["search"]=false;

$cols2[] = $col;

$i->set_columns($cols2);

$i->set_actions(array(
"add"=>$roles['add'],
"edit"=>$roles['edit'],
"delete"=>$roles['delete'],
"view"=>$roles['view'],
"rowactions"=>false,
"export"=>false,
"autofilter" => false,
"search" => false,
"inlineadd" => false,
"showhidecolumns" => false
)
);

function add_Intern(&$data)
{
$SPLOCATION = $_GET["SPLOCATION"];
$data["INLOCATION"] = $SPLOCATION;

}

/*** End of Internment *****/

// render grid
$out = $g->render("list1");
$out2 = $h->render("list2");
$out3 = $i->render("list3");

?>

4 Answers
Abu Ghufran answered 10 years ago

Hello,

The defaultValue option will not work with detail grid, as it is rendered once when making grid html.
You can use $_GET["SPLOCATION"] in callback event, as you used in add_tern(&$data) function.

You will need an updated build, which i am emailing you.
Kindly override in lib/inc.

Don Mangold answered 10 years ago

Abu,

Still not getting the INLOCATION value filled with SPLOCATION. Code above is still valid.

Thanks

Abu Ghufran answered 10 years ago

If you are setting it in insert query data, it should be:

$data["params"]["INLOCATION"] = $SPLOCATION;

Don Mangold answered 10 years ago

Got it working. Thanks for your help.

Your Answer

8 + 13 =

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?