select2 and autofilter

Questionsselect2 and autofilter
Sergio Pulido asked 4 years ago

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:
function link_select2(id)
$('select[name='+id+'].editable, select[id='+id+']').select2({width:'95%', dropdownCssClass: 'ui-widget ui-jqdialog'});

5 Answers
Abu Ghufran answered 4 years ago

Please make sure you include the select2 JS files.

<link rel="stylesheet" href="//">
<script src="//"></script>


Sergio Pulido answered 4 years ago

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

Abu Ghufran answered 4 years ago

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.

Wa Wa answered 2 months ago

$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);

Abu Ghufran Staff answered 2 months ago

When using select2, you must pass some label in order to have blank value.

Try this:
$col[“editoptions”] = array(“value”=>”:-;”.$str);

Abu Ghufran - Dev Team
PHP Grid Framework
Your Answer

0 + 6 =

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 / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!