Filter for field from related table

This issue affects filter functionality when first item in fields list is a field from a related table (added by setRelation function). In this case, at the first time opening the filter window, value field is not avaiable.

I’m using Grocery CRUD Enterprise version 2.8.7 with CodeIgniter 3.1.11 and PHP 7.3.27.

1 Like

Hello @dhyanan73 and welcome to our new forums :hugs:

I can reproduce the issue and I will try to fix that for the next version release. In any case I will inform this post.

At the meanwhile as a work-around if this is an important functionality for your CRUD and you can’t change the ordering of the fields then you also consider to add the below line:

$crud->fieldType('group', 'relational_native');

that will actually transform the searchable dropdown list into a native one.

Regards
Johnny

Hey, I found a little correction to fix this.

I changed the grocery_crud javascript file around line 7550 after Chosen.prototype.set_up_html = function () …

Before:

      container_props = {
        'class': container_classes.join(' '),
        'style': "width: " + this.container_width() + ";",
        'title': this.form_field.title
      };

After:

      container_props = {
        'class': container_classes.join(' '),
        'title': this.form_field.title
      };
      
        if(this.container_width() != "0px"){
                  container_props.style = "width: " + this.container_width() + ";";
        }

It’s a quick fix but not perfect because it’s width will be of the first element

the other way would be but i’m not sure of the side effects

        if(this.container_width() != "0px"){
                  container_props.style = "width: " + this.container_width() + ";";
        } else {
                  container_props.style = "width: 100%";
        }

I’m on GCE 2.9.3 btw

1 Like

I am glad to inform you that this is fixed on latest version 3.1.6