Scenario:
There is a table for districts and another table for (parent) cities/regions. The relation between the 2 tables is ONE-TO-MANY (regions-to-districts) as defined in relations() of the 2 Model classes as follows:
‘CityDistrict.php’:
'region' => array(self::BELONGS_TO, 'CityRegion', 'region_id'),
‘CityRegion.php’:
'cityDistricts' => array(self::HAS_MANY, 'CityDistrict', 'region_id'),
'cityDistrictsCount' => array(self::STAT, 'CityDistrict', 'region_id'),
The relation works just fine and all CRUD functions work as well as the additional count of all districts assigned to cities/regions. The only minor problem is the admin view of '‘CityRegion’ where the ‘# of districts’ is listed in 1 column, too. See image below. Questions:
-
How can I get rid of the “0” (see the highlighted input box); it’s 0 by default.
-
How could I possibly get this column to be sortable? For by now it’s not. The other columns work just fine.
Maybe there is a simple solution and I don’t see the forest for the trees… sigh.
Thanks for your help.