Select2 options are ignored in phpgrid 2.8 (ok in phpgrid 2.6)

QuestionsSelect2 options are ignored in phpgrid 2.8 (ok in phpgrid 2.6)
Alexander Toth asked 2 years ago

Hello,

I’ve a grid that works in phpgrid 2.6 but there are problems with phpgrid 2.8.
I’ve added the option tags: true in the select2 script so that one can add some free text in addition to the dropdown list values. In phpgrid 2.6 this works perfectly, in phpgrid 2.8 this customisation (and all other type of select2 options) are just ignored. I’ve checked the demo page to see if with phpgrid 2.8 the script is changed but nothing is changed.

$col = array();
$col[“title”] = “Group”;
$col[“name”] = “group”;
$col[“editable”] = true;
$col[“edittype”] = “select”;
$col[“editoptions”] = array(“value”=>’Admin:Admin;Quality control:Quality control;Customer care:Customer care;’);
$col[“editoptions”][“dataInit”] = “function(){ setTimeout(function(){ link_select2(‘{$col[“name”]}’); },200); }”;
$cols[] = $col;

<!– Dropdown Select2 –>
<script>
function link_select2(id)
{
$(‘select[name=’+id+’].editable, select[id=’+id+’]’).select2(
{
onSelect: function()
{
jQuery(this).trigger(‘change’);
},
tags: true
});
$(document).unbind(‘keypress’).unbind(‘keydown’);

$(‘select[name=’+id+’].editable, select[id=’+id+’]’).on(“select2:select”, function (evt) {
var element = evt.params.data.element;
var $element = $(element);
$element.detach();
$(this).append($element);
$(this).trigger(“change”);
});
}
</script>
<!– Dropdown Select2 –>

 

2 Answers
Abu Ghufran Staff answered 2 years ago

Hi,

Can you please share the screenshot of the both behaviors.
I’m getting same behavior in 2.6 and 2.8.

If you can do screen recording showing the issue, It would help.
https://www.screencastify.com/

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 2 years ago

One more thing, Please check if the jQuery library files included for select2 are of same version.

It may be possible that your previous may be using older version of select2 while latest uses a newer.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

20 + 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?