Hi abu I have a problem using select2 with grid, the select2 works fine if I use it from the grid I can search and edit records fine, but if I try to edit or add records using the form, it does not work, every time I write something to filter data, some other field starts focusing over and over
$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;
$col[“editrules”] = array(“required”=>true);
$cols[] = $col;
$col = array();
$col[“formatter”] = “select”;
$col[“title”] = “<i class=’fas fa-file-contract’></i> DIBUJO DE 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> DIBUJO DE SOLDADURA”;
$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> DIBUJO DE 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> DIBUJO DE ROSCADO”;
$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_lookup2 = $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
// all row, blank row, then all db values. ; is separator
$str = “:;”.$client_lookup2;
$col[“stype”] = “select”; // render as select
$col[“searchoptions”] = array(“value” => $str, “separator” => “:”, “delimiter” => “;”);
$col[“searchoptions”][“dataInit”] = “function(){ setTimeout(function(){ $(‘select[name=id_dibujo_roscado]’).select2({width:’80%’, dropdownCssClass: ‘ui-widget ui-jqdialog’}); },200); }”;
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=> $client_lookup2); // with these values “key:value;key:value;key:value”
$col[“editoptions”][“dataInit”] = “function(){ setTimeout(function(){ $(‘select[name=id_dibujo_roscado]’).select2({width:’80%’, dropdownCssClass: ‘ui-widget ui-jqdialog’}); },200); }”;
$col[“editrules”] = array(“required”=>true);
$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;
$col = array();
$col[“title”] = “<i class=’fas fa-file-excel’></i> GENERAR”;
$col[“name”] = “consultar”;
$col[“width”] = “15”;
$col[“editable”] = false;
$col[“align”] = “center”;
$col[“default”] = “GENERAR”;
$col[“search”] = false;
$col[“link”]= “http://srvverapp07/equipo/metlab/sistema_especificaciones_generar_orden.php?
&id={id}”;
$cols[] = $col;
/* $col = array();
$col[“title”] = “<i class=’fas fa-calendar-alt’></i> FECHA DE REGISTRO”;
$col[“name”] = “fecha”;
$col[“width”] = “25”;
$col[“editable”] = false;
$col[“align”] = “center”;
$col[“search”] = true;
$col[“formatter”] = “date”;
$col[“searchoptions”][“sopt”] = array(“cn”);
$col[“formatoptions”] = array(“srcformat”=>’Y-m-d’,”newformat”=>’d/F/Y’);
$cols[] = $col; */
// $grid[“url”] = “”; // your paramterized URL — defaults to REQUEST_URI
$grid[“rownum”] = 30; // by default 20
$grid[“sortname”] = ‘id’; // by default sort grid by this field
$grid[“sortorder”] = “desc”; // ASC or DESC
$grid[“caption”] = “SALES ORDER”; // caption of grid
$grid[“autowidth”] = true; // expand grid to screen width
$grid[“multiselect”] = TRUE; // allow you to multi-select through checkboxes
$grid[“loadtext”] = “Buscando… <i class=’fas fa-search’></i>”;
$grid[“altRows”] = true;
$grid[“rowactions”] = TRUE; // allow you to multi-select through checkboxes
// excel visual params
$grid[“add_options”] = array(‘width’=>’400’);
$grid[“edit_options”] = array(‘width’=>’400′);
$grid[“cellEdit”] = true; // inline cell editing, like spreadsheet
$grid[“rownumbers”] = true;
$grid[“rownumWidth”] = 35;
$grid[“add_options”][“success_msg”] = “<i class=’fas fa-check’></i> Registro guardado.”;
$grid[“edit_options”][“success_msg”] = “<i class=’fas fa-check’></i> Registro modificado.”;
$grid[“delete_options”][“success_msg”] = “<i class=’fas fa-check’></i> Registro borrado.”;
$grid[“shrinkToFit”] = true;
$grid[“add_options”][“jqModal”] = true;
$grid[“add_options”][“modal”] = true;
$grid[“edit_options”][“jqModal”] = true;
$grid[“edit_options”][“modal”] = true;
// export XLS file
// export to excel parameters
$grid[“export”] = array(“format”=>”excel”, “filename”=>”Usuarios”, “sheetname”=>”users”);
$grid[“export”][“range”] = “filtered”;
// RTL support
// $grid[“direction”] = “rtl”;
$g->set_options($grid);
$g->set_actions(array(
“add”=>TRUE, // allow/disallow add
“edit”=>true, // allow/disallow edit
“delete”=>TRUE, // allow/disallow delete
“rowactions”=> false, // show/hide row wise edit/del/save option
“export”=>false, // show/hide export to excel option
“autofilter” => true, // show/hide autofilter for search
“clone” => false, // clone record
“search” => false // show single/multi field search condition (e.g. simple or advance)
)
);
$g->select_command = “SELECT inicio.id,inicio.item,inicio.id_dibujo_soldadura,inicio.id_dibujo_final,inicio.id_dibujo_bandas,inicio.id_dibujo_roscado,inicio.id_box_pin,inicio.id_sales_order,
header.conexion,header.cliente
FROM metlab.sistema_especificaciones_inicio_orden inicio
INNER JOIN metlab.sistema_especificaciones_registrar_header header ON inicio.id_sales_order = header.id”;
//$g->select_command = “SELECT * FROM metlab.sistema_especificaciones_inicio_orden”;
$g->table = “metlab.sistema_especificaciones_inicio_orden”;
$g->set_columns($cols);
Can you share screenshot?
Everytime I write on the select2 field, the field (marked in red) starts focusing over and over
I tested this case and this issue is fixed in latest build.
Please email me your order number ([email protected]) to get update.
I dont have order number since Im working for someone else and I dont think my boss wants that update since he has been working like this forever, is there any other solution?
You can try adding unbind after select2 call:
setTimeout(function(){….},200); $(document).unbind(‘keypress’).unbind(‘keydown’);
I think you should contact your management to get update.
Try moving unbind just after select2 call:
setTimeout(function(){
// .select2()
$(document).unbind(‘keypress’).unbind(‘keydown’);
},200);
Try moving unbind just after select2 call:
setTimeout(function(){
// .select2()
$(document).unbind(‘keypress’).unbind(‘keydown’);
},200);