Make column readonly on add form

QuestionsMake column readonly on add form
Anand asked 6 months ago

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;
“`

2 Answers
Anand answered 6 months ago

Gist link here

Abu Ghufran Staff answered 1 week ago

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.

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

7 + 18 =

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?