hello mi file actual is jqgrid_dist of 164 kb, I have problem for select2, no inicialice, and firebug, no errors. What happened?. my code:
$col = array();
$col["title"] = "Cliente";
$col["name"] = "IdCliente";
// this is required as we need to search in name field, not id
$col["dbname"] = "ha_clientes.IdCliente";
$col["width"] = "120";
$col["align"] = "left";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select"; // render as select
$str = $grid->get_dropdown_values("select distinct IdCliente as k, Nombre as v from ha_clientes");
$col["editoptions"] = array("value"=>$str);
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col["IdCliente"]}'); },200); }";
$col["stype"] = "select"; // render as select
$col["searchoptions"] = array("value"=>$str);
$col["searchoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('gs_{$col["IdCliente"]}'); },200); }";
$cols[] = $col;
… too copy style,of demo and add my page.
In body page:
<script>
function link_select2(id)
{
$('select[name='+id+'].editable, select[id='+id+']').select2({width:'95%', dropdownCssClass: 'ui-widget ui-jqdialog'});
$(document).unbind('keypress').unbind('keydown');
}
</script>
Please make sure you include the select2 JS files.
<link rel="stylesheet" href="//cdn.jsdelivr.net/select2/3.5.2/select2.css">
<script src="//cdn.jsdelivr.net/select2/3.5.2/select2.min.js"></script>
Code: http://phpgrid.org/demo/demos/integrations/dropdown-select2.phps
works ok, but I happen to have a second, "select" because it is a page "detall master" and the second "select" not let me write.
I use Firefox, and at the bottom I get "javascript: void (0)"; when I try to make changes.
Thanks, Sergio Pulid0
In your code,
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col["IdCliente"]}'); },200); }";
the var: $col["IdCliente"] – should be: $col["name"]. e.g.
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col["name"]}'); },200); }";
The variable is $col["IdCliente"] is not defined and may be causing conflict. By setting $col["name"], the select2 will always have different id.
$col[“edittype”] = “select”; // render as select
$col[“editoptions”] = array(“value”=>”:;”.$str);
$col[“editoptions”][“dataInit”] = “function(){ setTimeout(function(){ link_select2(‘{$col[“name”]}’); },200); }”;
why the resultant drop down option does not contain a blank option although this is supplied? array(“value”=>”:;”.$str);
When using select2, you must pass some label in order to have blank value.
Try this:
$col[“editoptions”] = array(“value”=>”:-;”.$str);