Yii2: Create a custom column to filter records based on a condition

68 Views Asked by At

I have a table of sales lines which include promo, service, and item columns among others. These 3 columns contain IDs from other tables. A sales line can only have a value for one of these fields e.g. if promo is not null, then the other 2 should be.

I have no problem with displaying the records since I have a description column that displays the corresponding description of any of the IDs. What I want to do is create a custom column to create a filter on the gridview that would select records that are for either service, promo, or item sales. Sor of like:

'filter' => ['Service' => 'service_id != null', 'Promo' => 'promo_id != null', 'Item' => 'item_id != null'],

I know the code above would not work but this is the general idea.

Thank you in advance!

I haven't tried anything yet since I don't really know where to start.

0

There are 0 best solutions below