Yii Framework Forum: ArrayDataProviderEx - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

ArrayDataProviderEx Rate Topic: -----

#1 User is offline   Alexandr Dorogikh 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 29-September 09
  • Location:Ukraine, Bila Tserkva

Posted 10 June 2010 - 08:11 AM

Hello guys.

Today I needed to view arrays through CGridView. I had to write two classes: ArrayDataProviderEx and ArrayModel.

$a = array(
   'key1' => 'value1',
   'key2' => 'value2',
   'key3' => 'value3',
);

$dataProvider=new ArrayDataProviderEx($a, ArrayDataProviderEx::ARRAY_ASSOC);

// .....

// somewhere in view
$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'placeholders-values',
	   'dataProvider'=>$dataProvider,
	   'columns'=>array(
        'key',
        'value',
    ),
));


or

$a = array(
   array('color'=>red, 'model'=>'BMV Z5'),
   array('color'=>silver, 'model'=>'Audi A6'),
   array('color'=>black, 'model'=>'Audi A8'),
);

$dataProvider=new ArrayDataProviderEx($a, ArrayDataProviderEx::ARRAY_ORDER);

// .....

// somewhere in view
$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'placeholders-values',
	   'dataProvider'=>$dataProvider,
	   'columns'=>array(
        'color',
        'model',
    ),
));


More ;-) details available on my site.
If you are interested in these classes please visit ArrayDataProviderEx
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users