Using A Dynamic Number Of Clistview In Page

Thus far, I have only used CListView with the search scenario/method, and to return results against a single model. I would now like to use multiple lists within a page. I have the following related models:


class Area extends CActiveRecord {


  public function relations() {

    return array(

	'groups' => array(self::HAS_MANY, 'Group', 'area_id')

    );

  }


}


class Group extends CActiveRecord {


  public function relations() {

    return array(

	'people' => array(self::HAS_MANY, 'Person', 'group_id')

    );

  }


}


class Person extends CActiveRecord {


}

I want to create a view that displays all groups (i.e. a dynamic number) within an area, then each group has its own CListView to allow for pagination of the people within it. I have made several attempts at this, but to no avail, as basically I’m unsure on how to write the controller action so that pagination page changes can find their way back to their related group. Can anyone advise?

Thanks.

Hi girlafraid,

So, you want a nested CListViews like the following, don’t you?




An Area ... has a CListView of Group

    Group #1 ... has a CListView of Person

        Person #1-1

        Person #1-2

        ...

        Person #1-N

    Group #1 ... also has a CListView of Person

        Person #2-1

        Person #2-2

        ...

        Person #2-N

    ...

    Group #N ... also has a CListView of Person

        Person #N-1

        Person #N-2

        ...

        Person #N-N



And every CListView should paginate properly …

It seems possible using nested partial views, but also seems a little complicated and will need some effort.

I would start with a simplified version, for example, without pagination on the 2nd level CListViews.

[EDIT]

Applying unique IDs to every CListView should be the key point, when you want the proper pagination in all of them.