Hi, how can i have a selected master grid value (e.g. supplier id) available in detailed grid when creating a new record. It is possible to have this for edit existing recs, by using "default", but this is not working when adding a new record. Only the value from script start is available then.
Step1: Pass mydata (column name) in subgridparams in master grid
$opt["subGrid"] = true;
$opt["subgridurl"] = "subgrid_detail.php";
$opt["subgridparams"] = "mydata"; // comma sep. fields. will be POSTED from parent grid to subgrid, can be fetching using $_POST in subgrid
$grid->set_options($opt);
Step2: Read passed data.
for extra params passed from parent (e.g. company), we need some persistent storage in session for ajax calls
if (!empty($_POST["mydata"]))
$_SESSION["mydata"] = $_POST['mydata'];
$mydata = $_SESSION['mydata'];
Step2: Use in columns defaultVal
$col["editoptions"] = array("size"=>20, "defaultValue"=>$mydata);
….
A little fix is also required in jqgrid_dist.php.
search "session_start();", and remove the IF condition above it.
Hi, unfortunately this is not the solution for my problem and I'm also not using the subgrid (yet). The "id" ("defaultValue"=>$mydata) which I need in the detail grid is not updated when selecting another row in the master grid. It only updates on a full refresh.
Any other solution? What I need is a method where new records in the detail grid are connected (by MySQL table) to the selected row (id) in the master grid.
Thanks in advance for your suggestions! br. Richard
Hello,
Please refer master-detail.php example. It do perhaps exactly what you are searching.
Clients (master grid)
Invoices (detail grid)
When ever an invoice is added, it is linked to selected client of master grid.
I'm emailing you too.
Hello, thanks I got it working now, however not by using $_GET, but by using a $_SESSION value that holds the $_GET value. Next thing I noticed is that "on_update" event is not called when using the inline edit. I use the function to do a calculation on the fields when updated. Any way to have this function called for inline edit as well (by clicking the "save" button)?