Cgridview With Filter Without Direct Relation

Hello everyone …

Summary : I need to filter on CGRIDVIEW , a column that does not belong to the model . This model also has no direct relationship , for example : ( Due- > agent_id ) .

About models: An agent has many actions , an action belongs to Agent and has one Order . Order has many due and due belongs to Order.

In a CGRIDVIEW using model Due , I want to show and filter a column Agent -> name , but have no direct relationship between agent and due

Follow my models :


Agent

'actions' = > array ( self :: HAS_MANY , ' Action ', ' agent_id ' ) ,


Action

 ' agent' = > array ( self :: BELONGS_TO , 'Agent ', ' agent_id ' ) ,

'order ' = > array ( self :: has_one , ' Order ', ' action_id ' ) ,


Order

' dues ' = > array ( self :: HAS_MANY , 'Due ', ' order_id ' ) ,

'action' = > array ( self :: BELONGS_TO , ' Action ', ' action_id ' ) ,


Due

'order ' = > array ( self :: BELONGS_TO , ' Order ', ' order_id ' ) ,

In due model , I created an attribute called public $ agent. So , I can name my column in CGRIDVIEW and show a search field , but the rest , I do not know how to do

My view :


' columns ' = > array (


 array ( 'name' = > ' agent' ,

                               'value' = > '$data->order->action->agent->name' ,

                               ' header' = > ' Agent ' ,

                        )

)

What do I do in the model due to power funcinar filter

Check into the MANY-TO-MANY relations. It is something like Order to Agent through Action, or some combination of tables.