Skip to content

Magento 2 grid uiComponent filters not work for custom string values

My column definition looks like this:

<column name="child_customer_id">
  <argument name="data" xsi:type="array">
     <item name="config" xsi:type="array">
        <item name="filter" xsi:type="string">text</item>
        <item name="label" xsi:type="string" translate="true">Invited Person Registered</item>
        </item>
  </argument>
</column>

My Collection logic looks like this :

   protected function _initSelect()
 {
    parent::_initSelect();
    $planName = array('Monthly','Semi-Annual','Annual','Annual with custom design');
    $this->getSelect()->join(
        ['secondTable' => $this->getTable('subscription_invitation')],
        'secondTable.parent_customer =main_table.customer_id',
        ['parent_customer', 'IF(secondTable.customer_email NOT IN ( SELECT email from customer_entity ) ,"No","Yes") AS child_customer_id', 'customer_email','created_date'])
        ->join(
        [
            'thirdTable' => $this->getTable('customer_entity')
        ],
        'secondTable.parent_customer =thirdTable.entity_id',
        [
            'entity_id',
            'email',
            'IF(secondTable.customer_email NOT IN ( SELECT email from customer_entity ) ,"",( SELECT created_at  FROM customer_entity WHERE  email= secondTable.customer_email ) ) AS created_at'
        ])
        ->where('main_table.subscription_period IN(?)',$planName)
        ->where('NOW() > `main_table`.`from_date` AND CURDATE() < `main_table`.`to_date`')
        ->group('secondTable.parent_customer')
        ->group('secondTable.customer_email');
    
    return $this;
}

So i am trying to display Yes/No based on if invited customer registered or not using this

'IF(secondTable.customer_email NOT IN ( SELECT email from customer_entity ) ,"No","Yes") AS child_customer_id'

So far this displays fine on grids but when i filter the values by Yes/No it doesn’t work properly.

Any suggestions what i might be missing ?