| Support Center

(Back to Website)

Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

No Editable but Viewable on Add

S19K15 Feb 12, 2018 10:35PM PKT

Hi, is there any way to have a field that is not editable but still viewable when add dialog box is displayed? I tried something without success.

For example:
$col_detail_prac = array();
$col_detail_prac["title"] = $WORDING_STUDENT;
$col_detail_prac["name"] = "IDStud";
$col_detail_prac["search"] = true;
$col_detail_prac["editable"] = false;
$col_detail_prac["editrules"] = array("required"=>true);
$col_detail_prac["show"] = array("list"=>true,"view"=>true,"edit"=>true,"add"=>true);
$cols_detail_prac[] = $col_detail_prac;


Also can this field have a value behind and a different string in front view like the select type of field but without being select?

For example:
$str_stud = $jqgrid->get_dropdown_values("SELECT DISTINCT IDNumb as k, Plat as v FROM student");
$col_detail_prac["editoptions"] = array("value" => $str_stud, "separator" => ":", "delimiter" => ";");

17 Community Answers

Best Answer
Abu Ghufran Feb 15, 2018 08:06PM PKT

It will be in $_GET If you set:

$grid["subgridparams"] = "idnumb,first,last";
given that first,last are column names of parent grid.

As they are strings, intval is not required.

$first = ($_GET["first"]);
$last = ($_GET["last"]);

View in conversation


Up 0 rated Down
Abu Ghufran Feb 12, 2018 11:04PM PKT PHP Grid - Support Center Engineer
Little clarification required.
Add dialog does have any data. It's usually a blank form to input data. How you want a view-only field there and what should be there to be viewed in add form.

If you can tell exact business case, i can suggest better.
Up 0 rated Down
S19K15 Feb 12, 2018 11:22PM PKT
Correct, i missed to clarify that i am reffering to a master-detail-tab-grid and i have selected a record on the master and the requirement is to display the refering record on the add dialog without being able to change it!
Up 0 rated Down
Abu Ghufran Feb 13, 2018 12:01AM PKT PHP Grid - Support Center Engineer

Screenshot: http://prntscr.com/idrzjy
Code: https://gist.github.com/gridphp/05bd222c0c262081640611b3594c26bd

Step1: In list1
$opt["add_options"]["afterShowForm"] = 'function() { var selr = jQuery("#list1").jqGrid("getGridParam","selrow"); jQuery("#client_id").val( selr ) }';
$grid->set_options($opt);

Step2: In list2
$col["editable"] = true;
$col["editoptions"] = array("readonly"=>"readonly", "style"=>"border:0");

Step3: In list2, to save on post back
$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);

function add_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["client_id"] = $id;
}


Up 0 rated Down
S19K15 Feb 13, 2018 12:17AM PKT
Thanks, is there any way to change the display value of id to First and Last Name using sql query in this field without beeing select type?
Up 0 rated Down
Abu Ghufran Feb 13, 2018 12:28AM PKT PHP Grid - Support Center Engineer
If your master grid has firstname column, then you can use

$opt["add_options"]["afterShowForm"] = 'function() {
var selr = jQuery("#list1").jqGrid("getGridParam","selrow");
var val = jQuery('#list1').jqGrid('getCell', selr, 'firstname');
jQuery("#client_id").val( val )
}';
Up 0 rated Down
S19K15 Feb 13, 2018 02:11PM PKT
Hi Abu, all of your answers are correct but i am trying to do a mixed of all these, so i will clarify it a little more.

I have a master-detail-tab-grids and the master contains the students, the detail contains the lessons which each student has taken.

When master is focused on a record the detail lesson grid is refreshing.
Done, with code:
$grid["detail_grid_id"] = "lessons";
$grid["subgridparams"] = "idnumb";

When detail is adding a record it gets the student id on a record the detail lesson grid is refreshing.
Done, with code:
$col_detail_prac = array();
$col_detail_prac["title"] = $WORDING_STUDENT;
$col_detail_prac["name"] = "IDStud";
$col_detail_prac["search"] = true;
$col_detail_prac["editable"] = false;
$col_detail_prac["editrules"] = array("required"=>true);
$cols_detail_prac[] = $col_detail_prac;

function lesson(&$data)
{
$id = intval($_GET["idnumb"]);
$data["params"]["IDStud"] = $id;
}

Regarding the detail grid, the ID of student on lesson table is the idnumb of student in student table and the column i use in order to store the IDStud in lesson table is displaying the id of student, so is possible to display the fisrt and last name of the student with sql in this column and behind the scenes the idnumb is stored in the database?

Then i want to display this first and last name predifined when add dialog box is open but with sql and not javascript using the $_GET["idnumb"] in order just to be sure the the record is going to be added belongs to the specified student.
Up 0 rated Down
Abu Ghufran Feb 13, 2018 03:55PM PKT PHP Grid - Support Center Engineer
I am sending you working demo of master detail with clients->invoices scenario.
https://gist.github.com/gridphp/05bd222c0c262081640611b3594c26bd
Up 0 rated Down
S19K15 Feb 14, 2018 05:46PM PKT
In you example, in the Detail-Grid, the [client_id] column is showing the id of client which is inherited from Master-Grid when added, it is not showing the First and Last Name of this client_id...
Up 0 rated Down
Abu Ghufran Feb 14, 2018 07:37PM PKT PHP Grid - Support Center Engineer
Referring above demo, here is the screenshot: http://prntscr.com/ieng1m
line 68
Up 0 rated Down
S19K15 Feb 14, 2018 07:52PM PKT
Yes Abu, i saw it, i mean on the Detail-Grid-Rows, there you display the ID as a number, i am asking if there is a way to change also this behavior also in the rows.
Up 0 rated Down
Abu Ghufran Feb 14, 2018 11:47PM PKT PHP Grid - Support Center Engineer
You can make inner join in detail grid sql_command to select full name and display on grid as column with editable:false.
You can make id column hidden on list and display rest.
$col["show"] = array("list"=>false,"edit"=>true,"add"=>true,"view"=>false);
Up 0 rated Down
S19K15 Feb 15, 2018 08:02PM PKT
Perfect Abu,
This solves one part of the requirement, the second one, with the first and last name on add dialog box can be done with javascript...

$opt["add_options"]["afterShowForm"] = 'function() {
var selr = jQuery("#list1").jqGrid("getGridParam","selrow");
var val = jQuery('#list1').jqGrid('getCell', selr, 'firstname');
jQuery("#client_id").val( val )
}';

but can i do it with php something like...

$first = intval($_GET["first"]);
$last = intval($_GET["last"]);
Up 0 rated Down
Abu Ghufran Best Answer Feb 15, 2018 08:06PM PKT PHP Grid - Support Center Engineer
It will be in $_GET If you set:

$grid["subgridparams"] = "idnumb,first,last";
given that first,last are column names of parent grid.

As they are strings, intval is not required.

$first = ($_GET["first"]);
$last = ($_GET["last"]);
Up 0 rated Down
S19K15 Feb 15, 2018 08:16PM PKT
Correct, sorry about that, and how can i set them on the add dialog box of the Detail-Grid?
Up 0 rated Down
Abu Ghufran Feb 15, 2018 09:22PM PKT PHP Grid - Support Center Engineer
perhaps I don't understand. i mean this was already told in previous reply http://prntscr.com/ieng1m
Up 0 rated Down
S19K15 Feb 15, 2018 10:16PM PKT
Yes but the value of First Name and Last Name for Add dialog box on Detail-Grid you got it with JavaScript! I need to get it with php!
Up 0 rated Down
Abu Ghufran Feb 16, 2018 05:43AM PKT PHP Grid - Support Center Engineer
Currently It's not doable with PHP code. There is some code limitation in our lib.

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Contact Us

  • Post a Public Question
  • Email Us
  • Live Chat!
  • Ask the Community

    Instructions

    • Paste complete code that is involved in your question. You can use pastebin.com to share code link.

    Screenshots or Online link of webpage is helpful in resolution. You can also send email at address mentioned below.

    • To report an issue, Write steps to regenerate the case.

    • For email support or live chat, Use gridphp@gmail.com and add it in Google Chat.
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete