Yii Framework Forum: Getdata Enclosure On Relational Ar? - Yii Framework Forum

Jump to content

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

Getdata Enclosure On Relational Ar? Rate Topic: -----

#1 User is offline   jwerd 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 28-August 10

Posted 21 March 2013 - 12:29 AM

I have a HAS_MANY relation but I want to put it into a CGridView from within call, eg:

'dataProvider'=>$tracker->stats, but when I set this I get the following error:
Fatal error: Call to a member function getData() on a non-object

But I can access them via Tracker->stats[0]->field.

Is there anyway to set this up so Cgridview can still be used?

thanks!
0

#2 User is offline   mirunho 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 19-December 12
  • Location:Gdansk, Poland

Posted 21 March 2013 - 02:14 AM

View Postjwerd, on 21 March 2013 - 12:29 AM, said:

I have a HAS_MANY relation but I want to put it into a CGridView from within call, eg:

'dataProvider'=>$tracker->stats, but when I set this I get the following error:
Fatal error: Call to a member function getData() on a non-object

But I can access them via Tracker->stats[0]->field.

Is there anyway to set this up so Cgridview can still be used?

thanks!


Stats is array in this case. You can set data 'dataProvider'=>$tracker and than display value of every stats with some function (because You have to change array to string).
0

#3 User is offline   seenivasan 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 620
  • Joined: 17-June 12
  • Location:Chennai,TamilNadu,India.

Posted 21 March 2013 - 06:20 AM

Dear Friend

You can use the CArrayDataProvider.
'dataProvider'=>new CArrayDataProvider($tracker->stats),


Regards.
0

#4 User is offline   jwerd 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 28-August 10

Posted 21 March 2013 - 08:21 AM

View Postseenivasan, on 21 March 2013 - 06:20 AM, said:

Dear Friend

You can use the CArrayDataProvider.
'dataProvider'=>new CArrayDataProvider($tracker->stats),


Regards.


wow this worked perfectly. thank you man!
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