I have a master-detail grid where I am trying to display ID and Name on the detail grid so users know what is the parent ID and Name for which they are adding the detail. Based on below configuration, name is passed to insert query that is sent to the detail table which I do not want. How can I make the name
column appear in grid and add form as readonly but not send to the table during insert.
“`
$grid->select_command = “SELECT a.id, a.acq_price, a.acquisition_date, a.payment_schedule, a.payment_id, a.payment, a.payment_date, a.version, a.asset_id, s.name as asset_name
FROM griddemo.acq_acquisition_info a
JOIN griddemo.acq_asset_info s ON a.asset_id = s.id
WHERE a.asset_id IN ($id_acq)”;
// this db table will be used for add,edit,delete
$grid->table = “acq_acquisition_info”;
$cols = array();
$col = array();
$col[“title”] = “id”;
$col[“name”] = “id”;
$col[“dbname”] = “a.id”;
$col[“hidden”] = true;
$cols[] = $col;
$col = array();
$col[“title”] = “Asset ID”;
$col[“name”] = “asset_id”;
$col[“dbname”] = “a.asset_id”;
$col[“editable”] = true;
$col[“editoptions”] = array(“readonly”=>”readonly”);
$cols[] = $col;
$col = array();
$col[“name”] = “asset_name”;
$col[“title”] = “Asset Name”;
$col[“dbname”] = “s.asset_name”;
$col[“width”]= “150” ;
$col[“editrules”][“readonly”] = true;
$col[“editable”] = true;
// shows defaultValue only on add dialog and readonly
$col[“editoptions”] = array(“readonly”=>”readonly”, “style”=>”border:0”);
$cols[] = $col;
“`
Hello,
This is a late reply, however if someone wants to have this function, it’s implemented in the demo.
https://www.gridphp.com/demo/demos/master-detail/master-detail.phps
Line 91: in afterShowForm event of detail grid, we read the selected row data from parent grid and show in the readonly column defined on Line 119.