How to show relational data in dataGrid Widget?

I have two tables "Orders" and "Customers", How can I show data using dataGrid Widget?

I am also using "EActiveDataProvider" extension and doing

              $dataProvider=new EActiveDataProvider('Orders', array(


		// 'scopes'=>array('charged'),


			 //'condition'=>'status=1 AND tags LIKE :tags',








	 $dataProvider->joinAll = true; // optional if you want to also join the *_MANY relations

	 $dataProvider->getData(); // will return a list of customers objects


	return $dataProvider;

and in view If I want to show Email from customers table, it shows error

<?php $this->widget(‘zii.widgets.grid.CGridView’, array(









Any suggestion will be highly appreciated

Could you give us the error that’s appearing, please?

The reason for the error is most likely because ‘Email’ is not a column in your orders table.

I’m not familiar with the EActiveDataProvider extension.

In the ‘columns’ array of your CGridView, try this:








in place of the ‘Email’ entry you have in your code sample.

Thanks but you are too late, I got solutions far earlier.

Can you post the solution here, so other people can learn?

OK, Here is what I did… This will fetch data from orders and customers tables.

$this->widget(‘zii.widgets.grid.CGridView’, array(




    'ID',          // display the 'ID' attribute

    'Amount',          // display the 'Amount' attribute

//'customers.FirstNameB',  // show attribute  'FirstNameB' from 'customers' relation

//'customers.LastNameB',  // show attribute  'LastNameB' from 'customers' relation

'customers.Email',  // show attribute  'Email' from 'customers' relation

    //'content:html',   // display the 'content' attribute as purified HTML

    array(            // display 'create_time' using an expression


        'value'=&gt;'date(&quot;M j, Y&quot;, &#036;data-&gt;Time)',





    'filter' =&gt; CHtml::listData(Customers::model()-&gt;few()-&gt;findAll(),'ID','FirstNameB'),

    'value' =&gt; 'Customers::model()-&gt;FindByPk(&#036;data-&gt;CustomerID)-&gt;FirstNameB',


    array(            // display a column with &quot;view&quot;, &quot;update&quot; and &quot;delete&quot; buttons