Readonly when cell value

QuestionsReadonly when cell value
jiga asked 6 years ago

Hi abu I have a problem using read-only function
I need to make a cell readonly depending on value of other cell
Also I need to set a default value depending on value of other cell
How can I do that?

$g = new jqgrid();

$col = array();
$col[“title”] = “Id”;
$col[“name”] = “id”;
$col[“width”] = “08”;
$col[“align”] = “center”;
$col[“hidden”] = true;
$cols[] = $col;
$col = array();
$col[“formatter”] = “select”;
$col[“title”] = “<i class=’fas fa-file-contract’></i> SALES ORDER”;
$col[“name”] = “id_sales_order”;
$col[“width”] = “20”;
$col[“editable”] = true;
$col[“align”] = “center”;
$col[“search”] = true;
# fetch data from database, with alias k for key, v for value
$client_lookup = $g->get_dropdown_values(“select distinct id as k, sales_order as v from metlab.sistema_especificaciones_registrar_header ORDER by id asc”);
# these 3 lines will make dropdown in search autofilter
$col[“stype”] = “select”;
// all row, blank row, then all db values. ; is separator
$str = “:;”.$client_lookup;
$col[“searchoptions”] = array(“value” => $str, “separator” => “:”, “delimiter” => “;”);
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=> $client_lookup); // with these values “key:value;key:value;key:value”
$col[“editrules”] = array(“required”=>true);
$cols[] = $col;
$col = array();
$col[“title”] = “<i class=’fas fa-industry’></i> CLIENTE”;
$col[“name”] = “cliente”;
$col[“width”] = “20”;
$col[“editable”] = false;
$col[“align”] = “center”;
$col[“search”] = true;
$col[“dbname”] = “header.cliente”;
$cols[] = $col;
$col = array();
$col[“title”] = “<i class=’fas fa-oil-can’></i> CONEXIÓN”;
$col[“name”] = “conexion”;
$col[“width”] = “20”;
$col[“editable”] = false;
$col[“align”] = “center”;
$col[“search”] = true;
$col[“dbname”] = “header.conexion”;
$cols[] = $col;
$col = array();
$col[“title”] = “<i class=’fas fa-file-alt’></i> ITEM”;
$col[“name”] = “item”;
$col[“width”] = “20”;
$col[“editable”] = true;
$col[“align”] = “center”;
$col[“search”] = true;
$cols[] = $col;
$col = array();
$col[“formatter”] = “select”;
$col[“title”] = “<i class=’fas fa-file-contract’></i> FINAL”;
$col[“name”] = “id_dibujo_final”;
$col[“width”] = “20”;
$col[“editable”] = true;
$col[“align”] = “center”;
$col[“search”] = true;
# fetch data from database, with alias k for key, v for value
$client_lookup = $g->get_dropdown_values(“select distinct id as k, nombre as v from metlab.sistema_especificaciones_dibujo_final ORDER by id asc”);
# these 3 lines will make dropdown in search autofilter
$col[“stype”] = “select”;
// all row, blank row, then all db values. ; is separator
$str = “:;”.$client_lookup;
$col[“searchoptions”] = array(“value” => $str, “separator” => “:”, “delimiter” => “;”);
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=> $client_lookup); // with these values “key:value;key:value;key:value”
$col[“editrules”] = array(“required”=>true);
$cols[] = $col;
$col = array();
$col[“formatter”] = “select”;
$col[“title”] = “<i class=’fas fa-file-contract’></i> HARDBANDING”;
$col[“name”] = “id_dibujo_soldadura”;
$col[“width”] = “25”;
$col[“editable”] = true;
$col[“align”] = “center”;
$col[“search”] = true;
# fetch data from database, with alias k for key, v for value
$client_lookup = $g->get_dropdown_values(“select distinct id as k, nombre as v from metlab.sistema_especificaciones_dibujo_soldadura ORDER by id asc”);
# these 3 lines will make dropdown in search autofilter
$col[“stype”] = “select”;
// all row, blank row, then all db values. ; is separator
$str = “:;”.$client_lookup;
$col[“searchoptions”] = array(“value” => $str, “separator” => “:”, “delimiter” => “;”);
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=> $client_lookup); // with these values “key:value;key:value;key:value”
$col[“editrules”] = array(“required”=>true);
$cols[] = $col;
$col = array();
$col[“formatter”] = “select”;
$col[“title”] = “<i class=’fas fa-file-contract’></i> BANDAS”;
$col[“name”] = “id_dibujo_bandas”;
$col[“width”] = “25”;
$col[“editable”] = true;
$col[“align”] = “center”;
$col[“search”] = true;
# fetch data from database, with alias k for key, v for value
$client_lookup = $g->get_dropdown_values(“select distinct id as k, nombre as v from metlab.sistema_especificaciones_dibujo_bandas_identificacion ORDER by id asc”);
# these 3 lines will make dropdown in search autofilter
$col[“stype”] = “select”;
// all row, blank row, then all db values. ; is separator
$str = “:;”.$client_lookup;
$col[“searchoptions”] = array(“value” => $str, “separator” => “:”, “delimiter” => “;”);
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=> $client_lookup); // with these values “key:value;key:value;key:value”
$col[“editrules”] = array(“required”=>true);
$cols[] = $col;
$col = array();
$col[“formatter”] = “select”;
$col[“title”] = “<i class=’fas fa-file-contract’></i> ROSCADO CAJA”;
$col[“name”] = “id_dibujo_roscado”;
$col[“width”] = “25”;
$col[“editable”] = true;
$col[“align”] = “center”;
$col[“search”] = true;
# fetch data from database, with alias k for key, v for value
$client_lookup = $g->get_dropdown_values(“select distinct id as k, nombre_dibujo as v from metlab.sistema_especificaciones_dibujo_roscado ORDER by id asc”);
# these 3 lines will make dropdown in search autofilter
$col[“stype”] = “select”;
// all row, blank row, then all db values. ; is separator
$str = “:;”.$client_lookup;
$col[“searchoptions”] = array(“value” => $str, “separator” => “:”, “delimiter” => “;”);
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=> $client_lookup); // with these values “key:value;key:value;key:value”
$col[“editrules”] = array(“required”=>true);
$cols[] = $col;
$col = array();
$col[“formatter”] = “select”;
$col[“title”] = “<i class=’fas fa-file-contract’></i> ROSCADO PERNO”;
$col[“name”] = “id_dibujo_roscado_perno”;
$col[“width”] = “25”;
$col[“editable”] = true;
$col[“align”] = “center”;
$col[“search”] = true;
# fetch data from database, with alias k for key, v for value
$client_lookup = $g->get_dropdown_values(“select distinct id as k, nombre_dibujo as v from metlab.sistema_especificaciones_dibujo_roscado_perno ORDER by id asc”);
# these 3 lines will make dropdown in search autofilter
$col[“stype”] = “select”;
// all row, blank row, then all db values. ; is separator
$str = “:;”.$client_lookup;
$col[“searchoptions”] = array(“value” => $str, “separator” => “:”, “delimiter” => “;”);
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=> $client_lookup); // with these values “key:value;key:value;key:value”
$col[“editrules”] = array(“required”=>true);
$col[“editrules”] = array(“required”=>true, “readonly”=>true, “readonly-when”=>array(“==”,”abu_what_should_I_do_when_id_box_pin_field_is_equal_to”)); //HERE IS THE PROBLEM
$cols[] = $col;
$col = array();
$col[“formatter”] = “select”;
$col[“title”] = “<i class=’fas fa-file-contract’></i> DESCRIPCIÓN”;
$col[“name”] = “id_box_pin”;
$col[“width”] = “18”;
$col[“editable”] = true;
$col[“align”] = “center”;
$col[“search”] = true;
# fetch data from database, with alias k for key, v for value
$client_lookup = $g->get_dropdown_values(“select distinct id as k, box_pin as v from metlab.box_pin ORDER by box_pin”);
# these 3 lines will make dropdown in search autofilter
$col[“stype”] = “select”;
// all row, blank row, then all db values. ; is separator
$str = “:;”.$client_lookup;
$col[“searchoptions”] = array(“value” => $str, “separator” => “:”, “delimiter” => “;”);
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=> $client_lookup); // with these values “key:value;key:value;key:value”
$cols[] = $col;

2 Answers
Abu Ghufran Staff answered 6 years ago

You can perform these opertions in afterShowForm event of dialog.

$opt[“edit_options”][“afterShowForm”] = “function(){ …. }”;

In this function, you can use jquery selectors and browser debug inspector to identify your input element and change it’s attributes.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
jiga answered 6 years ago

Could you provide any example?

Your Answer

5 + 14 =

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?