Yii Framework Forum: Can I Use 2 Models At Once In Cgridview? - Yii Framework Forum

Jump to content

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

Can I Use 2 Models At Once In Cgridview? Rate Topic: -----

#1 User is offline   clonevn 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 111
  • Joined: 25-March 13

Posted 05 May 2013 - 11:15 AM

Im on a situation that retrieve 2 list of models :A and B. The number of model A = number of model B in the both 2 lists. I would like to show off their combination of attributes in the view but dont know how. CGridView only accept one.
0

#2 User is offline   Fabrizio Caldarelli 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 334
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 06 May 2013 - 03:12 AM

Have you thought of doing a join directly in the model (Data Provider) ?

Or you could make a merge of data and insert them in CArrayDataProvider.
0

#3 User is offline   clonevn 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 111
  • Joined: 25-March 13

Posted 06 May 2013 - 03:31 AM

View PostFabrizio Caldarelli, on 06 May 2013 - 03:12 AM, said:

Have you thought of doing a join directly in the model (Data Provider) ?

Or you could make a merge of data and insert them in CArrayDataProvider.

For some reasons, they could not be joined from the database. So I try to merge them by creating new CFormModel within the attributes of both 2 models A and B, then assign their data to the array of new model object. Hope it work.
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